• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: global NSMutableDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: global NSMutableDictionary


  • Subject: Re: global NSMutableDictionary
  • From: Bill Bumgarner <email@hidden>
  • Date: Tue, 29 Jul 2008 11:04:45 -0700

On Jul 29, 2008, at 10:57 AM, Nathaniel Gottlieb-Graham wrote:
Why do externs seem to have to be NSStrings? Also, is this even the right way to go about having a read/write global NSMutableDictionary? If not, how would I do this?

The variables cannot point to anything that isn't a constant. @"foo bar" is a constant string and is handled differently by the compiler/ linker. [[NSMutableDictionary dictionary] retain] is not a constant and, thus, cannot be used to directly initialize a variable at time of declaration within a global scope.


Instead, you need to initialize the variables as early as needed within your application.

This could be done in main(). Or it could be done in the +initialize for a class.

Or you could annotate a function as a constructor. It will run before main().

static void __InitializeGlobalStuffMan(void) __attribute__ ((constructor));
void __InitializeGlobalStuffMan(void) {
myGlobalDictionary = [[NSMutableDictionary alloc] init];
....
}


b.bum

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

  • Follow-Ups:
    • Re: global NSMutableDictionary
      • From: "Michael Ash" <email@hidden>
References: 
 >global NSMutableDictionary (From: Nathaniel Gottlieb-Graham <email@hidden>)

  • Prev by Date: global NSMutableDictionary
  • Next by Date: Re: Repositioning a content view w/in a window
  • Previous by thread: global NSMutableDictionary
  • Next by thread: Re: global NSMutableDictionary
  • Index(es):
    • Date
    • Thread