• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: init function return value
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >init function return value (From: "Chong Hiu Pun" <email@hidden>)

  • Prev by Date: Re: 2 classes
  • Next by Date: Re: cocoa-dev digest, Vol 2 #1032 - 16 msgs
  • Previous by thread: Re: init function return value
  • Next by thread: 2 classes
  • Index(es):
    • Date
    • Thread