Wednesday, August 1, 2012

Tips: How to find if NSDictionary has a key.



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



1 comment:

  1. It is much faster to use

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

    ReplyDelete