Re: Weird release problem on iPhone code
Re: Weird release problem on iPhone code
- Subject: Re: Weird release problem on iPhone code
- From: Noah Desch <email@hidden>
- Date: Thu, 18 Mar 2010 23:52:11 -0400
You don't own any of those objects so you should not be releasing them.
See:
http://developer.apple.com/mac/library/documentation/cocoa/conceptual/MemoryMgmt/Articles/mmRules.html
-Noah
On Mar 18, 2010, at 11:43 PM, William Squires wrote:
> I have some code like below in a UITableView delegate (specifically, the one that fires when you touch a tableview row):
>
> ...
> NSDictionary *store = [self.stores objectAtIndex:indexPath.row];
>
> // store name is like "NOBLE FINANCE" or "CUSTOMER CREDIT" or such; i.e. two strings seperated by a space
> NSString *temp = [store objectForKey:kKeyStoreName];
> NSString *temp2 = [store objectForKey:kKeyCity];
> NSArray *storeComponents = [temp componentsSeperatedByDelimiter:@" "];
> NSString *temp3 = [NSString stringWithFormat:"%@ %@", [storeComponents objectAtIndex:0], temp2];
> cell.label.text = temp3;
> // [temp3 release];
> // [storeComponents release];
> // [temp2 release];
> // [temp release];
> // [store release];
> ...
>
> If I uncomment any of the object releases above, the app crashes in the simulator, and all the call-stack items are gray (non-user code). But if I don't release them, they'll leak memory, won't they, since iPhone OS doesn't have GC?
> Note that I've verified that 'store' is actually an NSDictionary, and temp, temp2, and temp3 are non-NIL at the time they're released.
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden