`

ios遍历NSDictionary的方法

 
阅读更多

对于已知的key,可以用下面的代码取到value:

NSNumber *code = [response objectForKey:@"code"];

如果要遍历NSDictionary,可以用下面的代码:

        NSDictionary *dict = [datas objectAtIndex:0];
        NSArray *keys = [dict allKeys];// 所有key
        for(int i=0;i<[keys count];i++){
            NSString *key = [keys objectAtIndex:i];
            [dict objectForKey:key];
        }


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics