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

Re: Memory Management


  • Subject: Re: Memory Management
  • From: "Mike Vannorsdel" <email@hidden>
  • Date: Mon, 6 Aug 2001 10:54:11 -0600

Please see the Allocation and Initialization section of Object Oriented Programming and the Objective-C Language book that's included with the developer tools:

"Because an init... method might return an object other than the newly allocated receiver, or even return nil, it's important that programs use the value that's returned by the initialization method, not just that returned by alloc or allocWithZone:. The following code is very dangerous, since it ignores the return of init.

id anObject = [SomeClass alloc];
[anObject init];
[anObject soemOtherMessage];"

Reading that, you'll learn a lot and get a very good grasp on what should be done and when.


On Sunday, August 5, 2001, at 06:51 PM, Nat! wrote:

Misleading, because they give the impression that super init... could
return something else but self. But if it would return nil, the code
would crash because of NULL pointer exception when setting ivars later
in the code. It would crash also, if there was a different object
returned, because it would certainly not be of our subclass (see below)
and writing ivars (like myArray) would clobber memory.


References: 
 >Re: Memory Management (From: Nat! <email@hidden>)

  • Prev by Date: Re: Automatically scrolling to the bottom
  • Next by Date: [ANN] Vermont Recipes 4 pdf files delayed
  • Previous by thread: Re: Memory Management
  • Next by thread: Re: Memory Management
  • Index(es):
    • Date
    • Thread