Wednesday, August 1, 2012

Tips: How to find if NSDictionary has a key.



if ([[myDiction allKeys] containsObject:@"myKey"])
    NSLog(@"It contains myKey");



2 comments:

  1. It is much faster to use

    if ([myDictionary objectForKey:@"myKey"] != nil) {
    //contains key if not nil
    }

    ReplyDelete