• 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: Newbie question on Methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie question on Methods


  • Subject: Re: Newbie question on Methods
  • From: Karim Morsy <email@hidden>
  • Date: Sun, 12 Mar 2006 18:02:40 +0100

Bobby,

NSArray *fileTypes = [NSArray arrayWithObject:@"td"];

most cocoa classes provide this kind of class method.
those are convenience constructors and the created objects are added to the autorlease pool (i.e. unless explicitly retained, they get destroyed before the next run loop cycle).
you usually create an object that way if you're only using it temporarily.
So actually the method above is a wrapper and its implementation most likely looks like this:
+ (NSArray *)arrayWithObject:(id)anObject{
NSArray *tempArray= [[NSArray alloc] initWithObjects: anObject, nil]; // the newly created object gets retained here (-> retain count= 1)
return [tempArray autorelease]; // before the array is returned it gets sent autorelease
}


regards,
Karim


_______________________________________________ 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
  • Prev by Date: Re: transparent overlay NSWindow
  • Next by Date: Re: Sheet in a non-document-based Application
  • Previous by thread: Re: Newbie question on Methods
  • Next by thread: Re: Newbie question on Methods
  • Index(es):
    • Date
    • Thread