• 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 Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Init Question


  • Subject: Re: Init Question
  • From: Ambroise Confetti <email@hidden>
  • Date: Sun, 26 Oct 2003 01:34:58 +0200

Le 26 oct. 03, ` 00:33, Jon Hull a icrit :

What is the proper behavior of an initialization method if it is passed bad data?

It seems by example (NSArray's initWithContentsOfFile:) that I should return nil which is fine, but how do I prevent a memory leak, since alloc has already been called?

If an initializer method returns nil, then it has already released the object. You don't have to care about releasing it yourself.
(An initializer can also substitute the alloc'ed object with another. That's why you must absolutely reassign self to the value returned by the initializer of the superclass in your own initializer.)


Ambroise

http://www.cellulo.info/
_______________________________________________
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: Init Question
      • From: Jon Hull <email@hidden>
References: 
 >Init Question (From: Jon Hull <email@hidden>)

  • Prev by Date: Re: XCode for Jaguar?
  • Next by Date: Re: Init Question
  • Previous by thread: Init Question
  • Next by thread: Re: Init Question
  • Index(es):
    • Date
    • Thread