I want to check if an NSDictionary
is empty. I am doing it like this.
mutDictValues = [[[NSUserDefaults standardUserDefaults] objectForKey:@\"dicV
As most of the answers have correctly pointed out that you are passing un-recognized selector objectForKey:
to a NSString
instance instead of NSDictionary
, hence observing exception
-[__NSCFConstantString objectForKey:]:
Check NSUserDefaults
to see whether cities
returns a dictionary or something else. You can do this by two ways
I. NSLog
all data in NSUserDefaults
NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
II. Check the plist file which store the NSUserDefaults
from the Application folder. Check this answer for more details.
Hope that helps.
if ( [mutDictValues count] == 0 ) {
//code here
}
else {
//code here
}
After having your dic retrieved this should do