Thursday, May 9, 2013

NSDictionary enumerateKeysAndObjectsWithOptions example ios


enumerateKeysAndObjectsWithOptions :usingBlock:

Applies a given block object to the entries of the dictionary.
- (void)enumerateKeysAndObjectsWithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(id key, id obj, BOOL *stop))block
Parameters
opts
Enumeration options.
block
A block object to operate on entries in the dictionary.
Discussion of [NSDictionary enumerateKeysAndObjectsWithOptions]
If the block sets *stop to YES, the enumeration stops.
Example of [NSDictionary enumerateKeysAndObjectsWithOptions]
[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);
}];