Re: Releasing by reference
Re: Releasing by reference
- Subject: Re: Releasing by reference
- From: mmalc crawford <email@hidden>
- Date: Wed, 1 Aug 2007 07:16:52 -0700
On Aug 1, 2007, at 7:02 AM, Scott Morrison wrote:
Your +[QTMovie movieWithFile:error:] method is a factory method --
meaning that the object returned is autorealeased.
This is not necessarily the case.
The only statement is it appropriate to make is:
"You take ownership of an object if you create it using a method whose
name begins with “alloc” or “new” or contains “copy” (for example,
alloc, newObject, or mutableCopy), or if you send it a retain message."
(<http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html
>)
Whether or not an object you receive from a "convenience constructor"
is autoreleased per se is an orthogonal issue.
Memory management can be tricky but the key thing to remember that
each object should take care of the ownership of memory it is
using. AVOID at all costs anything where an object is created(or
retained) in once class/instance and to be released in another. --
This is at best misleading. It is perfectly reasonable to return from
a method an object to be released by the sender. The caveat is that
you should ensure that the method name follows the convention stated
above.
mmalc
_______________________________________________
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