显示字典对象

时间:2012-07-25 10:53:04

标签: objective-c cocoa-touch xcode4.3

我想仅显示每个对象,仅用于此字典(电子邮件,城市,名称): { “contact_search”:{ “0”:{ “电子邮件”: “XXX”, “城市”: “XXX”, “姓名”: “XXX”}}}

1 个答案:

答案 0 :(得分:1)

很难说出你真正想要的是什么。

NSDictionary *contactSearch = [dictionary objectForKey:@"contact_search"];

[dictionary enumerateKeysAndObjectsUsingBlock:^(id key, NSDictionary *contact, BOOL *stop) {
    NSString *name  = [contact objectForKey:@"name"]; 
    NSString *city  = [contact objectForKey:@"city"];
    NSString *email = [contact objectForKey:@"email"];

    NSLog(@"name: %@, city: %@, email: %@", name, city, email);
}];

这将获取对象字典,然后循环显示每个键/值对打印值