• 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: Memory Management and objects creation via static methods...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Management and objects creation via static methods...


  • Subject: Re: Memory Management and objects creation via static methods...
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 24 Mar 2008 21:54:16 -0700


On 24 Mar '08, at 9:19 PM, Samvel wrote:

Should I retain string in init?

Yes. When you store an object pointer in an instance variable you almost always want to retain it, so the object pointed to won't get deleted. If the pointer came from an "init" method, that object is already retained and you can just assign it to the instance variable. But if you got it through any other source, including a class factory method like +[NSString stringWith....], then the object has _not_ been retained for you, and if you want to keep a reference you'll need to call -retain yourself.


…Or you could just enable garbage collection and not have to deal with all this crap. It just means your app will require 10.5 or later.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >Memory Management and objects creation via static methods... (From: Samvel <email@hidden>)

  • Prev by Date: Where is it better to register with NSNotificationCenter in class?
  • Next by Date: Re: Memory Management and objects creation via static methods...
  • Previous by thread: Re: Memory Management and objects creation via static methods...
  • Next by thread: Re: Memory Management and objects creation via static methods...
  • Index(es):
    • Date
    • Thread