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

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

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

16条回答
  •  广开言路
    2020-11-28 01:35

    if ( [dictionary[@"data"][@"action"] isKindOfClass:NSNull.class ] ){
       //do something if doesn't exist
    }
    

    This is for nested dictionary structure

提交回复
热议问题