• 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: Returning nil from -init
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Returning nil from -init


  • Subject: Re: Returning nil from -init
  • From: Chris Ridd <email@hidden>
  • Date: Thu, 13 Mar 2003 07:03:25 +0000

On 12/3/03 9:58 am, Aram Greenman <email@hidden> wrote:
> On Wednesday, March 12, 2003, at 01:18 AM, Chris Ridd wrote:
>
>> I've got an init method that can fail if some of the input contains
>> incorrect data, and I understand the correct approach is to return nil
>> in
>> this case. But it isn't clear to me what to do with the partial object
>> pointed at by self in this case. Is calling dealloc or release
>> appropriate?
>>
>
> release.

I guess that works correctly since NSObject is one of the superclasses and
therefore [super init] has initialized the ref counting stuff.

That makes sense.

> The only other change I would make to the code you posted is to just
> return nil instead of assigning nil to self and returning self, but
> that's mostly style.

Or religion :-)

Thanks for the replies everyone!

Cheers,

Chris
_______________________________________________
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: Returning nil from -init (From: Aram Greenman <email@hidden>)

  • Prev by Date: Re: Dictionary keys(Solved)
  • Next by Date: Re: Creating a Singleton Object
  • Previous by thread: Re: Returning nil from -init
  • Next by thread: RE: Returning nil from -init
  • Index(es):
    • Date
    • Thread