• 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: When to 'release' in Cocoa management?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When to 'release' in Cocoa management?


  • Subject: Re: When to 'release' in Cocoa management?
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Fri, 21 Aug 2009 15:07:17 +0200


Don't try to guess what implementation is, and what variable's life- time will be. Just follow the rules.


You don't create the date object (by calling alloc or new or copy, …) you don't have to release it.


Le 21 août 2009 à 14:50, DairyKnight a écrit :

Thanks for the reply. So the implementation of :
NSDate *date = [dateFormatter dateFromString:@"0 : 0"];

is something like:
return [[NSString alloc] init.... autorelease];

And as the autoreleasepool gets drained in every event loop, the NSDate
object was released?



On Fri, Aug 21, 2009 at 6:19 PM, Graham Cox <email@hidden> wrote:



On 21/08/2009, at 7:08 PM, DairyKnight wrote:

One more thing, it has nothing to do with the DateFormatter. So somehow
UIDatePicker released its date somewhere
outside of my code... I guess it has something to do with autoreleasepool.




Well, yes, obviously.

If this seems mysterious to you, you just need to get in there and read the
documentation. Very thoroughly. You won't be able to get far with Cocoa
without knowing this stuff forwards, backwards, upside-down and in your
sleep.


Also, don't peer at retain counts or log them out - that way madness lies.
Just learn the rules and stick to 'em.


--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


_______________________________________________

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: 
 >When to 'release' in Cocoa management? (From: DairyKnight <email@hidden>)
 >Re: When to 'release' in Cocoa management? (From: Graham Cox <email@hidden>)
 >Re: When to 'release' in Cocoa management? (From: DairyKnight <email@hidden>)
 >Re: When to 'release' in Cocoa management? (From: DairyKnight <email@hidden>)
 >Re: When to 'release' in Cocoa management? (From: Graham Cox <email@hidden>)
 >Re: When to 'release' in Cocoa management? (From: DairyKnight <email@hidden>)

  • Prev by Date: iPhone: Accessing variable from another view controller
  • Next by Date: Re: iPhone: Accessing variable from another view controller
  • Previous by thread: Re: When to 'release' in Cocoa management?
  • Next by thread: Re: When to 'release' in Cocoa management?
  • Index(es):
    • Date
    • Thread