• 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
don't understand -[MyDocument init]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

don't understand -[MyDocument init]


  • Subject: don't understand -[MyDocument init]
  • From: Jérôme Laurens <email@hidden>
  • Date: Thu, 31 Oct 2002 16:24:38 +0100

Hi all,

I am currently using jaguar dev tools, and the template for MyDocument
subclass located at
/Developer/ProjectBuilder\ Extras/Project\ Templates/Application/Cocoa\
Document-based\ Application/MyDocument.m
puzzles me. The initializer is

- (id)init
{
[super init];
if (self) {

// Add your subclass-specific initialization here.
// If an error occurs here, send a [self dealloc] message and
return nil.

}
return self;
}

I am wondering how self has been given a chance to change its value.
Unless self is passed by address to the inherited init method (as an
hidden parameter), self won't change and the above test on self is
useless. A better pattern seems to be

- (id)init
{
if (self = [super init]) {

// Add your subclass-specific initialization here.
// If an error occurs here, send a [self dealloc] message and
return nil.

}
return self;
}
Did I miss something?
_______________________________________________
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.

  • Follow-Ups:
    • Re: don't understand -[MyDocument init]
      • From: David Remahl <email@hidden>
  • Prev by Date: Newbie Font Spacing Question
  • Next by Date: Re: don't understand -[MyDocument init]
  • Previous by thread: Newbie Font Spacing Question
  • Next by thread: Re: don't understand -[MyDocument init]
  • Index(es):
    • Date
    • Thread