Skip to content

Instantly share code, notes, and snippets.

@TiernanKennedy
Created March 26, 2013 18:39
Show Gist options
  • Save TiernanKennedy/5247962 to your computer and use it in GitHub Desktop.
Save TiernanKennedy/5247962 to your computer and use it in GitHub Desktop.
New Obj C Syntax
// Updates to LLVM give us better instantiation methods
NSNumber *n1 = @1000; // [NSNumber numberWithInt:1000]
NSNumber *n2 = @3.1415926; // [NSNumber numberWithDouble:3.1415926]
NSNumber *c = @'c'; // [NSNumber numberWithChar:'c']
NSNumber *b = @YES; // [NSNumber numberWithBool:YES]
Arrays
// before
NSArray *words = [NSArray arrayWithObjects:@"list", @"of", @"words", nil];
// after (array with some strings and numbers)
NSArray *words = @[@"list", @"of", @"words", @123, @3.14];
Dictionaries
NSDictionary *d = @{
@"key": @"value",
@"name": @"Joris",
@"n": @1234,
@3: @"string"
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment