Re: Are these the same and correct?
Re: Are these the same and correct?
- Subject: Re: Are these the same and correct?
- From: Sherm Pendley <email@hidden>
- Date: Mon, 14 Nov 2005 15:08:20 -0500
On Nov 14, 2005, at 2:51 PM, Brian O'Brien wrote:
NSNumber *n = [[[NSNumber alloc] initWithShort:val] autorelease];
and
NSNumber *n = [NSNumber numberWithShort:val];
Perhaps I should have specified my assumptions that a) there is an
autorelease pool in place and that b) val is an unsigned short.
It doesn't matter.
Internally, numberWithShort: might very well be implemented as
"return [[[self alloc] initWithShort:val] autorelease];", in fact in
this specific case I'd guess that it probably is.
But as a general rule that's an implementation detail that you don't
need to worry about. Other "convenience methods" - [NSApplication
sharedApplication] for example - return objects that have not been
autoreleased. But it doesn't matter. The point is that you're not
responsible for releasing them later; whether that's because they've
already been autoreleased, or because they're singletons, or
constants, or whatever, is immaterial.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
_______________________________________________
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