Skip to content

Instantly share code, notes, and snippets.

@paolonl
Forked from ksm/gist:3689574
Last active December 20, 2015 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paolonl/6201381 to your computer and use it in GitHub Desktop.
Save paolonl/6201381 to your computer and use it in GitHub Desktop.
How to get a constant literal container to work.
/*
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