Here is some code I have in my app that I DIDNT release. When I try to release I get a Program received signal: “EXC_BAD_ACCESS”. exception and the app crashes. If I dont try to release it the app runs fine.
Do I need to call a release message on these objects? Any idea what could be going on here?
NSString *sA = legA.text;
NSArray *firstLeg = [sA componentsSeparatedByString:@","];
[sA release]; //works ok
[firstLeg release]; //sends the bad access exception and crashes the app
Both of them don’t need to be
-released.I suggest you read the Memory Management Rules. You need to
-releasean object if and only if the current scope is an owner of that object. You become an owner only when the object is received as[[Foo alloc...] init...][foo new...][foo copy...]or[foo mutableCopy...][foo retain]in all other cases, you should never
-releaseit. As.textand-componentsSeparatedByString:are not one of these methods, there’s no need to-releasesAandfirstLeg.