Re: Init with something....
Re: Init with something....
- Subject: Re: Init with something....
- From: Daniel Jalkut <email@hidden>
- Date: Sat, 9 Dec 2006 23:53:57 -0500
Hi Sandro - what you're discovering on your own is exactly the
phenomenon covered by Apple's documentation of the "designated
initializer":
http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaFundamentals/CocoaObjects/chapter_3_section_6.html#//apple_ref/
doc/uid/TP40002974-CH4-SW3
It's OK for you to have more than one initializer (e.g.
initWithFile:) but you generally have a single designated initializer
through which all other initializers will call. In your case, "init"
is the designated initializer, so any other initializers in your
class will call through to it *instead* of super. The designated
initializer is the point at which the superclass init is incorporated
into the class.
Daniel
On Dec 9, 2006, at 10:29 PM, Sandro Noel wrote:
Greetings.
Another one,
when i create a class,
I override the init like this,...
- (id) init{
if ((self = [super init])) {// superclass may return nil
// do init code here.
}
return self;
}
but what if i want to init with a file's content,
I still want to call the init method, for my normal init code to run.
so would this be a good way of doing it ?
of am i over/miss doing it again ....
- (id) initWithFile:(NSString *) path{
if ((self = [self init])) {
[self loadFile:path];
}
return self;
}
again thank you and please forgive, if my questions seem very
beginner type :)
Sandro Noel.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
sweater.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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