IOS 字面量语法

作者: 小暖风 | 来源:发表于2017-08-19 17:37 被阅读4次

    字面量语法:

    NSNumber* intNum =@5;

    NSNumber* floatNum =@1.4f;

    NSNumber* boolNum =@YES;

    NSArray* array =@[@"dog",@"cat"];

    NSString* dog = array[0];

    id object1 = /* … */;

    id object2 = /* … */;

    id object3 = /* … */;

    NSArray * arrayA = [NSArray arrayWithObjects:object1,object2,object3,nil];

    NSArray * arrayB = @[object1,object2,object3];

    字面量语法创建字典,键在值得前面

    NSDictionary* dic =@{@"firstName":@"王",@"lastName":@"小哥"};

    NSString * lastName = dic[@“lastName”];

    相关文章

      网友评论

        本文标题:IOS 字面量语法

        本文链接:https://www.haomeiwen.com/subject/kvntdxtx.html