iPhone检查空字典

Tig*_*ger 4 iphone dictionary ios

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

这不适合我.检查空标签

Mat*_* S. 27

使用count.

例如:

if ([dict count] == 0) {
     NSLog("empty");
}
Run Code Online (Sandbox Code Playgroud)

如果要检查密钥,请执行以下操作:

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