Reputation: 38162
What is the best bet between:
#define kYes @"Yes"
AND
static NSString *const kYes = @"Yes";
And
NSString *kYes = @"Yes";
from memory consumption point of view. Keeping in mind that there will be thousands of constants in the application.
Upvotes: 11
Views: 2620
Reputation: 7645
From the memory stand point - static variable is better, since it's referenced once. The #define will insert the string into all the occurrences, by that - multiplying the memory usage... (that is unless GCC optimizing same constant string occurrences, which it actually might. in that case - there is no difference)
Upvotes: 11