Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone Check Empty dictionary

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

This is not working for me. to check empty tag

like image 449
Tiger Avatar asked Nov 27 '22 11:11

Tiger


1 Answers

Use count.

For example:

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

If you want to check for a key then:

if([dict objectForKey:@"photo"]) {
    NSLog(@"There's an object in photo");
}
like image 81
Matt S. Avatar answered Dec 25 '22 05:12

Matt S.