Created
September 10, 2012 08:05
-
-
Save ksm/3689574 to your computer and use it in GitHub Desktop.
Constant literal container workaround
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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