Re: global NSMutableDictionary
Re: global NSMutableDictionary
- Subject: Re: global NSMutableDictionary
- From: "I. Savant" <email@hidden>
- Date: Tue, 29 Jul 2008 14:16:32 -0400
On Tue, Jul 29, 2008 at 1:57 PM, Nathaniel Gottlieb-Graham
<email@hidden> wrote:
> I am trying to implement a global variable that's an NSMutableDictionary.
In addition to Bill's response, I'd like to take a different
direction. :-) Why are you trying to implement this as a global?
Typically (in the world of Cocoa), you'd have some central controller
that acts as your "app delegate". This controller would keep
references to things you might want to access from any part of your
app.
Consider having a controller class designated as your app's
delegate. Assume your dictionary is an instance variable of that
controller called "fooDict". Your app delegate controller would
contain a convenience method to return (or create and return) that
dictionary:
- (NSMutableDictionary *)fooDict
{
// Possibly create (and ensure retention of) fooDict here
return fooDict;
}
... then, from anywhere in your app, you can ask the controller for
its fooDict like this:
id fooDict = [[NSApp delegate] fooDict];
I hope this helps (or is at all relevant to your goal).
--
I.S.
_______________________________________________
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