Object-c集合和字典

1、集合数组创建

    NSMutableArray *bleDeviceArray = [[NSMutableArray alloc]initWithCapacity:0]
    [bleDeviceArray addObject:@{@"name":@"device"}];

2、结构体创建

 NSDictionary *data = @{
                        @"code":@"0",
                        @"result":@"",
                    };

3、判断是否有这个key

 NSDictionary *data = @{
                        @"code":@"0",
                        @"result":@"",
                    };
if([[data allKeys] containsObject:@"second"]){
}

4、取值

 NSDictionary *data = @{
                        @"code":@"0",
                        @"result":@"",
                    };
NSString *mac = [data objectForKey:@"code"]

你可能感兴趣的:(Object-c集合和字典)