Skip to content

Instantly share code, notes, and snippets.

@ksm
Created September 10, 2012 08:05
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ksm/3689574 to your computer and use it in GitHub Desktop.
Constant literal container workaround
/*
Source: WWDC2012 Modern Objective-C talk
How to get a constant literal container to work.
*/
@implementation MyClass
static NSArray *thePlanets;
+ (void)initialize {
if (self == [MyClass class]) {
thePlanets = @[
@"Mercury", @"Venus", @"Earth",
@"Mars", @"Jupiter", @"Saturn",
@"Uranus", @"Neptune"
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment