如何检查字典中的键是否与方法参数中的字符串相同?即在下面的代码中,dictobj 是 NSMutableDictionary 的对象,对于 dictobj 中的每个键,我需要与字符串进行比较。如何做到这一点?我应该键入 NSString 的键吗?
-(void)CheckKeyWithString:(NSString *)string
{
//foreach key in NSMutableDictionary
for(id key in dictobj)
{
//Check if key is equal to string
if(key == string)// this is wrong since key is of type id and string is of NSString,Control doesn't come into this line
{
//do some operation
}
}
}