NSString* kMyKey = @"aKey" vs #define MYKEY @"aKey"
NSString* kMyKey = @"aKey" vs #define MYKEY @"aKey"
- Subject: NSString* kMyKey = @"aKey" vs #define MYKEY @"aKey"
- From: Memo Akten <email@hidden>
- Date: Fri, 3 Apr 2009 22:41:25 +0100
I was wondering if there is much difference between:
NSString* kMyKey = @"aKey";
// and then throughout the application:
[myDictionary setObject:xxx forKey:kMyKey];
[myDictionary objectForKey: kMyKey];
vs
#define MYKEY @"aKey"
// and then throughout the application:
[myDictionary setObject:xxx forKey: MYKEY];
[myDictionary objectForKey: MYKEY];
The docs say the strings created with the @ construct are created at
compile time. Does that mean potentially if we use the define 50
times, there are 50 NSStrings with identical content created at
compile time? Or does the compiler optimize that as well?
_______________________________________________
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