1

New Objective-C Literals

 1 year ago
source link: https://fann.im/blog/2012/11/21/new-objective-c-literals/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

New Objective-C Literals

Nov 21, 2012

NSArray:

NSInteger _appid = 12345;
NSArray *array = @[ @"title", @(_appid)];

NSString *title = array[0];
array[0] = @"newTitle";

NSDictionary:

NSDictionary *dict = @{
    @"appid" : @(_appid),
    @"title" : _title,
};

NSString *title = dict[@"title"];
dict[@"title"] = @"newTitle";

NSNumber:

NSNumber *intNum = @123;
NSNumber *floatNum = @1.23f;
NSNumber *boolNum = @YES;

More: Objective-C Literals

Was this page helpful?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK