• 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: Properly writing an Init method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Properly writing an Init method


  • Subject: Re: Properly writing an Init method
  • From: jerome LAURENS <email@hidden>
  • Date: Thu, 18 Jul 2002 13:26:38 +0200

Le jeudi 18 juillet 2002, ` 06:35 AM, Julian Barkway a icrit :

Fair point. So what are the benefits of assigning to self in this way, rather than using, say,

if (![super init])
return nil;
// Init stuff...
return self;

I'm only asking because I recently had a problem which was caused by an object being typed to it's own superclass, rather than the class it should have been typed to, and it struck me this could have been caused by my use of 'self = [super init]'...


while not using assignment 'self = [super init...]', there might be a problem if super returns anything else than itself. It may occur when one creates a subclass of a singleton or instances of classes that use opaque types. However, this seems to be rare. But this allows further modifications of super implementation orthogonal to the implementation of self.
_______________________________________________
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: 
 >Re: Properly writing an Init method (From: Julian Barkway <email@hidden>)

  • Prev by Date: Re: [Seriously OT]Mac.com 60 days and counting
  • Next by Date: Re: [Seriously OT]Mac.com 60 days and counting
  • Previous by thread: Re: Properly writing an Init method
  • Next by thread: Re: Properly writing an Init method
  • Index(es):
    • Date
    • Thread