> 
>> I create another NSDate, on the stack, to hold "now" for use within that
>> function.  Do I need to retain that too?
> 
> Yes.

Not really, no. You could, it wouldn't be incorrect to retain it at the point 
of creation (or use alloc/init) and then release it at the end of the function, 
but it's not really necessary. The NSDate you create for 'now' should be valid 
through the function you made it in (likely it's on an autorelease pool which 
will be popped later)x

> 
> It would be a good idea to read Apple’s Memory Management documentation 
> before going any further, really.
> 
> http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html
> 

This is vital. You must read and understand this memory management stuff. It's 
surprising you got this far without understanding it, perhaps you've been using 
properties which do a lot of the memory management for you and you just stopped 
and started using instance variables directly. 

You might want to run some of your current code through Instruments if you 
haven't already done so and check memory allocations and leaks, if you were 
confused on the memory management rules, it's easy to fail the other way and 
leak objects by not releasing them. 


_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to