• 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: Which class methods return autoreleased objects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Which class methods return autoreleased objects?


  • Subject: Re: Which class methods return autoreleased objects?
  • From: Ricky Sharp <email@hidden>
  • Date: Mon, 6 Dec 2004 17:16:45 -0600

On Dec 6, 2004, at 3:36 PM, Jeremy French wrote:

Where in the documentation do you find out, whether or not a class method returns an autoreleased object?

For example, NSString has the method "stringWithFormat:", which returns an autoreleased NSString object. But when I look at the documentation, there is no mention that the object is being returned autoreleased.

The reference I used is "Foundation Reference for Objective-C", locating the "stringWithFormat:" under NSString. The documentation simply reads, "Returns a string created in the manner of localizedStringWithFormat:, but using the user’s default locale to format numbers. See 'Using Format Strings' for more information." (See <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ ObjC_classic/Classes/NSString.html#//apple_ref/doc/uid/20000154/ stringWithFormat_>)

So how do you determine when a class method returns an autoreleased object?

As the docs[1] mention, you basically just assume that they do. I don't think you'll find any explicit documentation on the individual APIs stating that assumption.


Also remember that when writing your own class methods that create instances, they too should always return them autoreleased. This will follow the proper pattern so that all objects can play nicely together.

[1] <http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/ Concepts/ObjectOwnership.html>

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Which class methods return autoreleased objects?
      • From: Paul Sargent <email@hidden>
    • Re: Which class methods return autoreleased objects?
      • From: Gwynne <email@hidden>
References: 
 >Which class methods return autoreleased objects? (From: Jeremy French <email@hidden>)

  • Prev by Date: Re: Which class methods return autoreleased objects?
  • Next by Date: coreaudio sdk -- for jaguar & project buider?
  • Previous by thread: Re: Which class methods return autoreleased objects?
  • Next by thread: Re: Which class methods return autoreleased objects?
  • Index(es):
    • Date
    • Thread