• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDictionary trouble
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSDictionary trouble
      • From: Shawn Rutledge <email@hidden>
References: 
 >NSDictionary trouble (From: Shawn Rutledge <email@hidden>)
 >Re: NSDictionary trouble (From: Jens Alfke <email@hidden>)
 >Re: NSDictionary trouble (From: Shawn Rutledge <email@hidden>)

  • Prev by Date: Re: NSDictionary trouble
  • Next by Date: MKPinAnnotationView callout behind other pins
  • Previous by thread: Re: NSDictionary trouble
  • Next by thread: Re: NSDictionary trouble
  • Index(es):
    • Date
    • Thread