In a word game for iPhone:
I\'m trying to use the following code in my custom view Tile.
You can use static, but the assignment can't be made on the same line. Try this:
- (void)awakeFromNib {
[super awakeFromNib];
static NSDictionary* letterValues = nil;
if (!letterValues) {
letterValues = @{@"A": @1,
@"B": @4,
@"C": @4,
// ...
@"X": @8,
@"Y": @3,
@"Z": @10};
}
...
}
The reason is that the @{
syntax is translated by the compiler into an Objective-C method ([[NSPlaceholderDictionary alloc] initWithObjects:forKeys:count:]
), which cannot be resolved at compile-time.