for each loop in Objective-C for accessing NSMutable dictionary

前端 未结 7 497
忘掉有多难
忘掉有多难 2020-11-30 16:45

I am finding some difficulty in accessing mutable dictionary keys and values in Objective-C.

Suppose I have this:

NSMutableDictionary *xyz=[[NSMutabl         


        
7条回答
  •  离开以前
    2020-11-30 17:17

    Just to not leave out the 10.6+ option for enumerating keys and values using blocks...

    [dict enumerateKeysAndObjectsUsingBlock:^(id key, id object, BOOL *stop) {
        NSLog(@"%@ = %@", key, object);
    }];
    

    If you want the actions to happen concurrently:

    [dict enumerateKeysAndObjectsWithOptions:NSEnumerationConcurrent
                                  usingBlock:^(id key, id object, BOOL *stop) {
        NSLog(@"%@ = %@", key, object);
    }];
    

提交回复
热议问题