Re: init function return value
Re: init function return value
- Subject: Re: init function return value
- From: Robert Fischer <email@hidden>
- Date: Thu, 1 Aug 2002 12:30:15 +0200
On Thursday, August 1, 2002, at 11:45 AM, Chong Hiu Pun wrote:
By default, the init function is defined as follows:
-(id)init
So after I did my initialization, what value should I return? Or I can
just
change (id) to (void) so that the warning:
"control reaches end of non-void function" can be eliminated?
thanks!
Please read the online documentation in
"/Developer/Documentation/Cocoa/ObjectiveC/" to get the basics of ObjC.
And please: read the warnings of the compiler and try to understand them.
To answer your question: you have to return self in this method after you
have initialized self's instance variables. You don't need to implement
this method, if no initialization is neccessary, but you have to call
[super init] if you implement it yourself. See docu of NSObject for
details.
CU,
Robert
--
--- - .-. -- --
--- / \ ---- Robert Fischer
.-. / \ --- .-. __o .-. @
/ \ / \ / \ _`\<,_ / \ berlin.de
/ \ / \ / \ (*)/ (*) / `--------------
/ `---' `-' `-----------'
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.