Skip to content

Instantly share code, notes, and snippets.

@oleganza
Created August 20, 2012 14:18
Show Gist options
  • Save oleganza/3404669 to your computer and use it in GitHub Desktop.
Save oleganza/3404669 to your computer and use it in GitHub Desktop.
Modern Objective-C
// 2011:
[container setObject:value forKey:[NSString stringWithFormat:@"%d", number]];
// 2012:
container[@(number).stringValue] = value;
@ondrejmirtes
Copy link

What does @(number) mean?

@Inza
Copy link

Inza commented Aug 20, 2012

It is a smart shortcut in this case for [NSNumber numberWithInt:number]...

But bad think about this is that if you use any of these new features, you will not compile your project on older version of Xcode :-/...

@dev4dev
Copy link

dev4dev commented Aug 21, 2012

you don't have to write ".stringValue", just "@(number)" is enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment