• 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: Noob question regarding Cocoa objects.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Noob question regarding Cocoa objects.


  • Subject: Re: Noob question regarding Cocoa objects.
  • From: Scott Ribe <email@hidden>
  • Date: Tue, 28 Nov 2006 11:49:27 -0700
  • Thread-topic: Noob question regarding Cocoa objects.

>> You can also call another init method in the same class, but in the
>> end the appropriate super class' init method must be called first
>> before you start initializing your object
>>
>>     - (id)initWithParam:(int)param
>>     {
>>         if ( (self=[self init]) != nil )
>>             {
>>             // [self init] did basic initialization
>>             // do more initialization with param here
>>             iVar = param;
>>             ...
>
> I guess you mean:
>
>      - (id)initWithParam:(int)param
>      {
>          if ( (self=[super init]) != nil )
>              {
>              // [super init] did basic initialization
>              // do more initialization with param here
>              iVar = param;
>              ...

You can perfectly well call init (or more properly, the designated
initializer, whatever it happens to be) in the same class, as long as the
super class init (or designated initializer) is called before the real setup
starts.


--
Scott Ribe
email@hidden
http://www.killerbytes.com/
(303) 722-0567 voice


_______________________________________________

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

  • Follow-Ups:
    • Re: Noob question regarding Cocoa objects.
      • From: Nir Soffer <email@hidden>
References: 
 >Re: Noob question regarding Cocoa objects. (From: Nir Soffer <email@hidden>)

  • Prev by Date: Re: Noob question regarding Cocoa objects.
  • Next by Date: Core Data, NSManagedObject & XML
  • Previous by thread: Re: Noob question regarding Cocoa objects.
  • Next by thread: Re: Noob question regarding Cocoa objects.
  • Index(es):
    • Date
    • Thread