• 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: Releasing by reference
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Releasing by reference (From: email@hidden)
 >Re: Releasing by reference (From: Stephane Sudre <email@hidden>)
 >Re: Releasing by reference (From: email@hidden)
 >Re: Releasing by reference (From: Scott Morrison <email@hidden>)

  • Prev by Date: Re: Releasing by reference
  • Next by Date: Re: Usefulness of a Cocoa DSP framework?
  • Previous by thread: Re: Releasing by reference
  • Next by thread: Re: Releasing by reference
  • Index(es):
    • Date
    • Thread