• 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: There's obviously something I don't understand about NSDate.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: There's obviously something I don't understand about NSDate.


  • Subject: Re: There's obviously something I don't understand about NSDate.
  • From: Roland King <email@hidden>
  • Date: Sun, 18 Mar 2012 07:55:42 +0800

Hmm - with respect - autorelease is an implementation detail. Nothing says that objects created through the convenience constructors like [ NSDate date ] have to be autoreleased, they just have to be valid for long enough to be useful, they could be held in a cache and cleaned out by little gnomes later.

This was a basic question of ownership, the important difference is that

	[ [ NSDate alloc ] init ];

returns an object you own and

	[ NSDate date ]

returns an object you do not. That's the key memory management takeaway here and is why you needed to retain the [ NSDate date ] when you put it in an instance variable (and release it later when you're done with it). No mention of autorelease pools there, just the concept of ownership.

On Mar 18, 2012, at 7:38 AM, G S wrote:

> I did read the memory-management docs a long time ago, and I've run my app through both Leaks and the analyzer.  I avoid using properties because I carefully manage my allocations.
>
> I think the hole in my knowledge was limited to autorelease.  I never use autorelease in my code, so my exposure to it is limited to those Cocoa functions that use it.


_______________________________________________

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: 
 >There's obviously something I don't understand about NSDate. (From: G S <email@hidden>)
 >Re: There's obviously something I don't understand about NSDate. (From: Dave Fernandes <email@hidden>)
 >Re: There's obviously something I don't understand about NSDate. (From: G S <email@hidden>)
 >Re: There's obviously something I don't understand about NSDate. (From: Charles Srstka <email@hidden>)
 >Re: There's obviously something I don't understand about NSDate. (From: Roland King <email@hidden>)
 >Re: There's obviously something I don't understand about NSDate. (From: G S <email@hidden>)

  • Prev by Date: Re: There's obviously something I don't understand about NSDate.
  • Next by Date: Re: There's obviously something I don't understand about autorelease.
  • Previous by thread: Re: There's obviously something I don't understand about NSDate.
  • Next by thread: Re: There's obviously something I don't understand about NSDate.
  • Index(es):
    • Date
    • Thread