• 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: NSUserDefaults objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUserDefaults objects


  • Subject: Re: NSUserDefaults objects
  • From: Robert Walker <email@hidden>
  • Date: Wed, 22 Mar 2006 16:10:58 -0500

Ondra,

Ahh yes.  Thanks for the clarification.

On Mar 22, 2006, at 3:38 PM, Ondra Cada wrote:

Robert,

On 22.3.2006, at 21:16, Robert Walker wrote:

In this case (as per the memory management documentation) I would assume that I am receiving an autoreleased object

That is not entirely correct: you should assume the object *might be* (but needs not to be) autoreleased. It can be shared, cached, whatever.


The memory management rules still, of course, do apply: if you want to keep it for longer than the scope of the current pool, retain it (presumably /auto/releasing it later, unless you want to keep it for ever).

Also note that in some cases it may be more prudent to retain/ autorelease at once, even if the usage does *not* go outside the current pool scope. That is an ufortunate result of widespread using plain accessors (instead of much safer autoreleasing ones). For example, this code

id p=[NSAutoreleasePool new];
id ttl=[somethingTitled title];
[something whatever];
NSLog(@"title %@",title);
[p release];

is potentially unsafe, alas (since nothing prevents the whatever method to create its own nested pool and inside it send [self setTitle:], rendering thus your original copy unuseable).
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc




-- Robert Walker email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSUserDefaults objects (From: "Chris Lewis" <email@hidden>)
 >Re: NSUserDefaults objects (From: Robert Walker <email@hidden>)
 >Re: NSUserDefaults objects (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: NSUserDefaults objects
  • Next by Date: Re: Develop for many platforms
  • Previous by thread: Re: NSUserDefaults objects
  • Next by thread: NSTabview shrinks too much
  • Index(es):
    • Date
    • Thread