ios 字典enumerateKeysAndObjectsUsingBlock遍历

enumerateKeysAndObjectsUsingBlock :使用代码块来迭代执行该集合中所有的key-value对


   NSDictionary *dict = @{@"a": @"1", @"b": @"2"};
    [dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop)
    {
        if ([@"1" isEqualToString:key])
        {
              NSLog(@"key: %@, value: %@", key, obj);
        }
        
        else
        {
         NSLog(@"key: %@, value: %@", key, obj);
        }
      
    }];

2015-10-13 21:51:11.326 CommonDemo[21438:289979] key: a, value: 1

2015-10-13 21:51:23.476 CommonDemo[21438:289979] key: b, value: 2


你可能感兴趣的:(ios 字典enumerateKeysAndObjectsUsingBlock遍历)