Re: split up alloc and init?
Re: split up alloc and init?
- Subject: Re: split up alloc and init?
- From: Quincey Morris <email@hidden>
- Date: Mon, 11 Feb 2008 00:52:35 -0800
On Feb 11, 2008, at 00:04, John Terranova wrote:
The self = [super init] discussion is interesting. Here is
something related that I came across just before the [super init]
discussion started. Basically, is it safe to split up alloc and init?
[NSInvocationOperation initWithTarget:selector:object:] takes an id
as the object parameter that will eventually get passed to the
selector parameter. What if I want to pass the operation object
itself to the selector? There is no setObject: to set it after
initializing. I must pass the object to init.... The only way to
do that is to split up the alloc and init.
Is this not the same question as assigning [super init]? Can I
count on the object that alloc returns being the exact same object
after init... returns?
No, you can't count on it. It's exactly the same question as assigning
self = [super init] -- you have to assume that an initializer might
return a different object, no matter where it is called.
See http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_13_section_3.html#/
/apple_ref/doc/uid/TP30001163-CH9-CJBBEEFH and notice the phrase "very
dangerous".
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden