Re: Newbie Question re Allocation & Initialization
Re: Newbie Question re Allocation & Initialization
- Subject: Re: Newbie Question re Allocation & Initialization
- From: Jack Repenning <email@hidden>
- Date: Mon, 19 May 2008 18:03:28 -0700
On May 19, 2008, at 5:18 PM, Brad Gibbs wrote:
Is it because numberToPrint is simply pointing to newNumber objects
in the array that have already been allocated and initialized?
Yes, both newNumber and numberToPrint are merely pointers to some
object. These objects are created in the first loop (the alloc/init
sequence you noticed), and then stored into the array (the 1addObject:
call). In the second loop, they already exist, but we want to grab
onto one so we can print it; numberToPrint is set to point to an
existing object inside the array (via -objectAtIndex:); since the
object already exists, it doesn't need to be alloc'ed (allocated as
sufficient blank memory to hold the object) or init'ed (fixed up to
actually be such an object).
-==-
Jack Repenning
email@hidden
Project Owner
SCPlugin
http://scplugin.tigris.org
"Subversion for the rest of OS X"
_______________________________________________
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