How to check if an NSDictionary or NSMutableDictionary contains a key?

前端 未结 16 2785
北海茫月
北海茫月 2020-11-28 00:52

I need to check if an dict has a key or not. How?

16条回答
  •  隐瞒了意图╮
    2020-11-28 01:37

    For checking existence of key in NSDictionary:

    if([dictionary objectForKey:@"Replace your key here"] != nil)
        NSLog(@"Key Exists");
    else
        NSLog(@"Key not Exists");
    

提交回复
热议问题