In game game for iPhone :

I am trying to use the following code in my custom Tile.m view :
- (void)awakeFromNib { [super awakeFromNib]; static NSDictionary* const letterValues = @{ @"A": @1, @"B": @4, @"C": @4, // ... @"X": @8, @"Y": @3, @"Z": @10, }; NSString* randomLetter = [kLetters substringWithRange:[kLetters rangeOfComposedCharacterSequenceAtIndex:arc4random_uniform(kLetters.length)]]; int letterValue = [letterValues[randomLetter] integerValue]; _smallLetter.text = _bigLetter.text = randomLetter; _smallValue.text = _bigValue.text = [NSString stringWithFormat:@"%d", letterValue]; }
Unfortunately, this gives me a compilation error. The Initializer element is not a compile-time constant , and I need to remove the static to get my application in Xcode (here in full screen ):

I think I'm initializing NSDictionary - with the new Objective-C Literals syntax .
But why can't I use static here?
I thought it would be appropriate for my letterValues constant letterValues be set only once?
ios static objective-c const nsdictionary
Alexander farber
source share