Re: Newbie: Referencing Objects
Re: Newbie: Referencing Objects
- Subject: Re: Newbie: Referencing Objects
- From: Nathan Kinsinger <email@hidden>
- Date: Sun, 26 Oct 2008 14:21:48 -0600
On Oct 26, 2008, at 2:05 PM, john fogg wrote:
Hi again!
Thank you everybody for your answers.
On Sun, Oct 26, 2008 at 7:45 PM, Andy Lee <email@hidden> wrote:
I don't know Actionscript but it looks like it has a global
dictionary of
objects that you can reference by name. There is nothing like
"_root" in
Objective-C.
I see, this is where I was wrong. Yes Actionscript has this global
dictionary. If you know the name of an object and its place in the
hierarchy you can access it.
In my game I think of having a sort of "controller object" that
controls the whole state of the game. So I'd like to access it from
almost every other object further down the hierarchy. How would you do
this?
Is there a way to create the controller object and store its reference
in a global variable? Or is there another common way to do this that
I'm not thinking of?
Sorry for asking such dumb questions but I'm still new to this.
Thanks again in advance!
(not a dumb question)
You want to use the singelton pattern, see:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_10.html
--Nathan
_______________________________________________
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