Re: Why would a defined selector not be found at runtime?
Re: Why would a defined selector not be found at runtime?
- Subject: Re: Why would a defined selector not be found at runtime?
- From: Sherm Pendley <email@hidden>
- Date: Thu, 12 May 2005 14:12:07 -0400
On May 12, 2005, at 11:37 AM, Ricky Sharp wrote:
On May 12, 2005, at 4:46 AM, Ken Tozier wrote:
NSDisclosureButtonCell *result =
[NSDisclosureButtonCell alloc];
// always chokes on the next line at runtime
[result initWithControlSize: inControlSize];
Hmm, I think this has something to do with splitting up the alloc
and init calls.
The problem with splitting those up is that -init* is not required to
return the object that received it. It might return nil, or even
another object.
So, in the above, result would be fine after the call to +alloc, but
if -init* returned nil or a different object, result would be a
wayward pointer.
Incidentally, if you *really* want to split up the +alloc and -init*
calls, you can, but you have to remember to re-assign the variable
with the return value from -init*:
NSFoo *anObject = [NSFoo alloc];
anObject = [anObject init];
This is a safe way to split them, but it's awkward and error-prone,
so hardly anyone ever uses it.
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