NSDictonary *dict = @{@"123":@"a";@"234":@:"b"};
判断字典中是否含有某个key
一:
if ([dict.allKeys containsObject:@"a"]) {
}
二:
[dict.allKeys enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isEqualToString:@"rightTitle"]) {
}
else//没有righttitle
{
}
}];
本文介绍了使用Objective-C进行字典操作的方法,包括如何检查字典中是否存在特定的键。通过示例代码展示了两种不同的检查方式,一种是利用allKeys属性结合containsObject方法,另一种则是通过enumerateObjectsWithOptions枚举字典的所有键。

9577

被折叠的 条评论
为什么被折叠?



