Re: Newbie question on Methods
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