Reputation: 581
I want to check if my Bond is empty or null and NULL value.
{
Bonds =(
{
DOB = "12/09/1988";
about = "";
}
);
User = {
city = CA;
email = "[email protected]";
};
success = True;
}
Second time this type get data how to check Bond key
{
Bonds = Null;
User = {
city = CA;
email = "[email protected]";
};
success = True;
}
Upvotes: 4
Views: 3555
Reputation: 198
check: if (![dataArray isKindOfClass:[NSNull class]])
&&
check if it having elements [dataArray firstObject]
- to check array having one or more elements.
Upvotes: 2
Reputation: 1783
The best possible way should be:
if (!data[@"Bonds"] || ![data[@"Bonds"] count]){
NSLog(@"Data Found");
}else{
NSLog(@"Data Not Found");
}
Upvotes: 1
Reputation: 1510
if ([data[@"Bonds"] isKindOfClass:[NSNull class]] || data[@"Bonds"] == nil || [data[@"Bonds"] isEqualToString:@""]) {
}
Upvotes: 5
Reputation: 61
[NSNull null] always returns a same object so this should work fine.
if (dictionary[@"Bonds"] != [NSNull null]) {
// requried data is present, now check if it is nil or empty.
}
Upvotes: 2
Reputation: 45490
You just check for nil
if(data[@"Bonds"]==nil){
NSLog(@"it is nil");
}
or
if ([data[@"Bonds"] isKindOfClass:[NSNull class]]) {
NSLog(@"it is null");
}
Upvotes: 7