Re: Are these the same and correct?
Re: Are these the same and correct?
- Subject: Re: Are these the same and correct?
- From: Chris Hanson <email@hidden>
- Date: Mon, 14 Nov 2005 11:20:32 -0800
On Nov 14, 2005, at 11:02 AM, Sherm Pendley wrote:
On Nov 14, 2005, at 1:43 PM, Brian O'Brien wrote:
NSNumber *n = [[[NSNumber alloc] initWithShort:val] autorelease];
and
NSNumber *n = [NSNumber numberWithShort:val];
They're *very* similar; in neither case are you responsible for
releasing n later.
But, as a matter of internal implementation details, there's no
guarantee that n is autoreleased in the second case, although it
quite often will be.
In the second case, you must always treat the object pointed to by
"n" as autoreleased; if you want to keep a reference to it, you need
to retain it.
-- Chris
_______________________________________________
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