• 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: Newbie Question re Allocation & Initialization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie Question re Allocation & Initialization


  • Subject: Re: Newbie Question re Allocation & Initialization
  • From: Nick Zitzmann <email@hidden>
  • Date: Mon, 19 May 2008 18:24:27 -0600


On May 19, 2008, at 6:18 PM, Brad Gibbs wrote:

It compiled and ran as expected, too. But, when I tried to eliminate allocation and initialization for newNumber in the first 'for loop', the app threw an exception. I don't see an explanation in the book re why numberToPrint can be, but doesn't need to be allocated or initialized. Is it because numberToPrint is simply pointing to newNumber objects in the array that have already been allocated and initialized? Could someone please explain this?


numberToPrint is a pointer to a memory address that may be an object; it is not an object itself. Creating a new object, and then replacing its only pointer with a pointer to a new object, is just wasting memory.

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Newbie Question re Allocation & Initialization (From: Brad Gibbs <email@hidden>)

  • Prev by Date: Newbie Question re Allocation & Initialization
  • Next by Date: Re: Newbie Question re Allocation & Initialization
  • Previous by thread: Newbie Question re Allocation & Initialization
  • Next by thread: Re: Newbie Question re Allocation & Initialization
  • Index(es):
    • Date
    • Thread