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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to