Re: NSDictionary trouble
Re: NSDictionary trouble
- Subject: Re: NSDictionary trouble
- From: Graham Cox <email@hidden>
- Date: Wed, 20 Jan 2010 08:38:45 +1100
On 20/01/2010, at 5:33 AM, Shawn Rutledge wrote:
> I forgot to mention, another problem I ran into was that my dictionary
> is a member variable of my UIViewController, I inited it in
> initWithNibName, then later when I go to use it in another member
> function, I found that it had been garbage-collected. I used other
> member variables the same way, but only the dictionary got
> garbage-collected. So I fixed it by doing [myDict retain]; in the
> initWithNibName, but didn't understand why such a thing should be
> necessary.
Uh-oh, category error.
UIViewController is an iPhone class, therefore you must be programming on iPhone, right? Which does not have garbage collection. Therefore your assumptions about what is happening are wrong. You MUST learn the memory management rules and have them down pat so you can write correctly managed code without having to really think about it.
--Graham
_______________________________________________
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