Re: Why "self"? (Was: Newbie: Referencing Objects)
Re: Why "self"? (Was: Newbie: Referencing Objects)
- Subject: Re: Why "self"? (Was: Newbie: Referencing Objects)
- From: "john fogg" <email@hidden>
- Date: Tue, 28 Oct 2008 04:30:33 +0100
Hi Ken!
Thank you for your long answer! It cleared up a lot of things for me.
I come from coding in Actionscript (Flash) and there things are
apparently quite different.
Is it true that all instances I create live in memory on the same
level? That they are all somehow equal? And that all relationships
between them are only by pointers?
Because in Actionscript you can have instances inside other object's
instances and once you dealloc the containing instance all the other
object's instances it contained die with it. Think Matryoshka puppets
or something like that.
On 10/28/08, Ken Thomases <email@hidden> wrote:
> Part of the problem is that object's don't have names, they have addresses.
I see. So I can only access an instance from within some other
instance if I always remember to pass along a pointer to it?
> But the pointer isn't the object and the object isn't the pointer.
This is what I got wrong I guess.
> So, when you say "I create a subobject called 'mySubObject' inside my
> main object 'myMainObject'" I translate that to mean, that you have a
> pointer named myMainObject to an instance of some custom class. In
> the implementation of that class, there's a method, and in that method
> you create another object of some other(?) class and store its address
> into a pointer named mySubObject. mySubObject might be a local
> variable, an instance variable, or whatever.
>
> Now, what does "within 'mySubObject'" mean? I assume you mean within
> an instance method of the class of which mySubObject is an instance.
Thank you. You translated correctly and explained it to me at the same time! :-)
Your following explanation did the trick for me. Thank you again!
Cheers, John.
_______________________________________________
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