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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to