Re: Newbie Question re Allocation & Initialization
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