On Dec 22, 2009, at 9:40 pm, Michael Craig wrote:

> At the point where the tutorial discusses garbage collection (end of ch. 5),
> I decided to implement the deallocation of the Converter objects created by
> ConverterController's convert: method. I want the deallocation to happen
> inside convert:. To test it, I'm using [converter retainCount], thinking
> that after the object is deallocated, that call will cause an error.
> 
This is the wrong way to think about memory management.
You shouldn't be thinking in terms of deallocating another object, only in 
terms of ownership. You want to relinquish ownership of an object when you've 
finished with it.  This is discussed in greater detail in 
<http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmObjectOwnership.html#//apple_ref/doc/uid/20000043>
 and the memory management rules summarised in 
<http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html#//apple_ref/doc/uid/20000994>.

To elaborate on bbum's messages, the documentation for retainCount is quite 
explicit...
<http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html#//apple_ref/occ/intfm/NSObject/retainCount>

mmalc

_______________________________________________

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

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

Reply via email to