Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Objective-c > Re: Questions a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 21 of 40 Topic 980 of 1039
Post > Topic >>

Re: Questions about memory management (was Re: I must be missing something... (Categories))

by Don Bruder <dakidd@[EMAIL PROTECTED] > May 23, 2008 at 09:49 PM

In article <wcyeo-B4F390.20591423052008@[EMAIL PROTECTED]
>,
 William Yeo <wcyeo@[EMAIL PROTECTED]
> wrote:

> In article <65idnaQoP5TqFKrVnZ2dnUVZ_uqdnZ2d@[EMAIL PROTECTED]
>,
>  Don Bruder <dakidd@[EMAIL PROTECTED]
> wrote:
> 
> OK, let's concentrate one one part at a time. You need to grok the 
> allocation and initiaization stages of object creation before anything 
> else will make sense. Otherwise all your objects will self-destruct at 
> random times (been there, done that, got the T-****rt :-)
> 
> Allocation and initialization first.
> 
> > > You really want [[MyButton alloc] init] instead.
> > 
> > But... Wait a minute... 
> > 
> > If I do that, I've got to have an "alloc" in the "MyButton" class, no?

> > Or does that feed back up the chain to whatever class (probably 
> > "NSObject"?) it is that "knows how" to alloc? 
> 
> If you don't supply one, it'll use the ancestor's version ... it's OOP -

> remember. The basic alloc method allocates enough storage for all of the

> data members in your object plus all of the data members in your 
> object's ancestors.

<light bulb>

Which means I don't need to write an "alloc" of my own... Hooray! And 
further, that "de-fogs" some of the confusion I've been having. NOW I 
think I've got it. (Remind me to set up an appointment at the clinic - I 
hear that these days, they've got pills that'll cure "it" in about 2 
weeks :) )

> > > It seems that if that's the case, I'd be getting back an object of 
> > whatever-class-it-was-that-said-"I know how to alloc", rather than a 
> > "MyButton"??? How does that object know how to init a "MyButton"???
> 
> 
> > > If you need to customize the initialization of your instances, you 
> > > provide an implementation for -init for that class. Within that 
> > > implementation, you will invoke some [super init...] variant.
> > 
> > Fair enough, and noted for future, but once again the answer I got
seems 
> > to "go around" the question I asked. 
> > 
> > Which "init" am I invoking when I do "[[super alloc] init]"? Am I 
> > invoking "super"'s init? The init of the object I just alloced?
> 
> You are not listening.

Trust me... I'm listening. But so far, I haven't heard the answer - Or 
if I have, it's come through garbled enough that I haven't been able to 
recognize it as BEING the answer.

> Consider [[MyObject alloc] init]
> 
> This uses [MyObject alloc] to create an instance (of type MyObject) and 
> allocate storage space for the data (contained in an MyObject instance).

> Once that has been done the [... init] is your chance to initialize the 
> data.

<light bulb redux>

Which, in combination with the first light bulb, means that the 
"- (MyObject *)init" method in the MyObject class is the "init" that 
runs...

<headsmack>

Hmmm... Methinks this is one of those epiphany things, no? 

I think I've got that part, now. But it would have been quicker if 
someone had just said "The init that runs is the init in the class of 
the object that you just alloc-ed", which is what I've been trying to 
figure out all along. Up to now, I've been under the impression - now 
clearly wrong - that the super's init was the one that was being 
invoked. Now that I've made the connection, it's fairly obvious.

Thanks. That's going to make things a bit smoother, I'm thinking.

'Scuse me whilst I go edit accordingly... This might take a while...

-- 
Don Bruder - dakidd@[EMAIL PROTECTED]
 - If your "From:" address isn't on my
whitelist,
or the subject of the message doesn't contain the exact text
"PopperAndShadow"
somewhere, any message sent to this address will go in the garbage without
my
ever knowing it arrived. Sorry... <http://www.sonic.net/~dakidd>
for more
info
 




 40 Posts in Topic:
I must be missing something... (Categories)
Don Bruder <dakidd@[EM  2008-05-13 08:37:26 
Re: I must be missing something... (Categories)
Tom Harrington <tph@[E  2008-05-13 10:18:36 
Re: I must be missing something... (Categories)
Gregory Weston <uce@[E  2008-05-13 13:44:52 
Re: I must be missing something... (Categories)
Don Bruder <dakidd@[EM  2008-05-13 11:10:55 
Re: I must be missing something... (Categories)
Gregory Weston <uce@[E  2008-05-13 13:44:44 
Re: I must be missing something... (Categories)
Don Bruder <dakidd@[EM  2008-05-13 11:36:45 
Re: I must be missing something... (Categories)
Gregory Weston <uce@[E  2008-05-13 15:28:22 
Re: I must be missing something... (Categories)
Gregory Weston <uce@[E  2008-05-13 15:41:52 
Re: I must be missing something... (Categories)
Don Bruder <dakidd@[EM  2008-05-13 14:54:17 
Re: I must be missing something... (Categories)
Gregory Weston <uce@[E  2008-05-13 18:04:18 
Re: I must be missing something... (Categories)
William Yeo <wcyeo@[EM  2008-05-13 15:14:21 
Re: I must be missing something... (Categories)
Don Bruder <dakidd@[EM  2008-05-13 16:02:00 
Re: I must be missing something... (Categories)
William Yeo <wcyeo@[EM  2008-05-13 16:41:09 
Re: I must be missing something... (Categories)
Don Bruder <dakidd@[EM  2008-05-13 18:15:56 
Re: I must be missing something... (Categories)
William Yeo <wcyeo@[EM  2008-05-13 21:38:25 
Re: I must be missing something... (Categories)
Gregory Weston <uce@[E  2008-05-14 07:28:07 
Questions about memory management (was Re: I must be missing som
Don Bruder <dakidd@[EM  2008-05-23 11:01:11 
Re: Questions about memory management (was Re: I must be missing
Gregory Weston <uce@[E  2008-05-23 17:22:47 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-23 20:20:10 
Re: Questions about memory management (was Re: I must be missing
William Yeo <wcyeo@[EM  2008-05-23 20:59:14 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-23 21:49:26 
Re: Questions about memory management (was Re: I must be missing
Gregory Weston <uce@[E  2008-05-24 09:01:37 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-24 22:06:12 
Re: Questions about memory management (was Re: I must be missing
Gregory Weston <uce@[E  2008-05-25 08:29:49 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-25 11:23:08 
Re: Questions about memory management
Sherman Pendley <spamt  2008-05-25 17:34:26 
Re: Questions about memory management (was Re: I must be missing
William Yeo <wcyeo@[EM  2008-05-24 13:11:43 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-24 22:20:17 
Re: Questions about memory management (was Re: I must be missing
William Yeo <wcyeo@[EM  2008-05-24 23:37:13 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-25 10:22:16 
Re: Questions about memory management (was Re: I must be missing
William Yeo <wcyeo@[EM  2008-05-25 10:59:31 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-25 11:43:32 
Re: Questions about memory management (was Re: I must be missing
Gregory Weston <uce@[E  2008-05-25 15:27:50 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-25 13:07:37 
Re: Questions about memory management (was Re: I must be missing
Gregory Weston <uce@[E  2008-05-26 07:30:16 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-26 07:30:02 
Re: Questions about memory management (was Re: I must be missing
glenn andreas <gandrea  2008-05-25 18:53:55 
Re: Questions about memory management (was Re: I must be missing
Gregory Weston <uce@[E  2008-05-24 08:57:32 
Re: I must be missing something... (Categories)
Matthias Benkard <usen  2008-05-14 15:26:05 
Re: I must be missing something... (Categories)
Matthias Benkard <mulk  2008-05-13 12:20:27 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 19:57:47 CDT 2008.