Re: global NSMutableDictionary
Re: global NSMutableDictionary
- Subject: Re: global NSMutableDictionary
- From: Nathaniel Gottlieb-Graham <email@hidden>
- Date: Tue, 29 Jul 2008 14:25:34 -0400
Holy moly, that's just what I needed. This dictionary in fact
originated in the controller app delegate, and I had no idea you could
reference things inside the app delegate like that! Thanks so much!
On Jul 29, 2008, at 2:16 PM, I. Savant wrote:
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