iPhone 检查空字典

标签 iphone ios dictionary

if ([dict objectForKey:@"photo"] !=(id)[NSNull null]) 
    {NSLOG(@"dictinary is not empty")}

这对我不起作用。检查空标签

最佳答案

使用计数

例如:

if ([dict count] == 0) {
     NSLog("empty");
}

如果你想检查一个 key ,那么:

if([dict objectForKey:@"photo"]) {
    NSLog(@"There's an object in photo");
}

关于iPhone 检查空字典,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11094707/

相关文章:

iphone - 在单击取消按钮之前,搜索栏不会显示结果

iphone - Safari 中不支持 XSLTProcessor() 吗?

ios - Xcode - 缺少架构(库链接)

iOS 13 状态栏样式无效(从未调用过 childForStatusBarStyle)

iOS 相当于 Android ValueAnimator

iphone - 细节较少的 iOS MapKit

ios - 在 didSelectRowAtIndexPath 之后禁用选择其他单元格

python - 以图形形式表示python字典

arrays - 从值字典数组中检索键

dictionary - 如果满足条件,则从字典中删除项目