判断NSDictionary是否包含某个key

方法一:


 if ( [ [ dictionary allkeys ] containsObject:key ] ) {

   // contains key

}

方法二:

 if ( [ dictionary objectForkey:key ] ) {  // objectForKdy will return nil if a key doesn't exists.

// contains key

} 

你可能感兴趣的:(key,Dictionary)