Check NSDictionary is Empty or not - Objective C
If you are an iOS developer you will need to use data type called NSDictionary.
When I m implementing web service access ( REST type , JSON output) I needed to populate data using using a NSDictionary. It worked fine but there was an issue coming when web service data is empty. So this case I had to find a way to check dictionary is empty or not either null or not.
I have tried below way but exception thrown.
[responseObject count];
Then I have tried and no errors was fired for empty list. Happy coding.
if([NSNull null] != [responseObject objectForKey:@"YOUR_JSON_OBJECT_NAME"]) {
//Wow this worked.
}
You can find my other article how to read REST full (JSON output) web service using AFNetworking library in iOS/Objective C. Just visit codehelpdesk.blogspot
You can find my other article how to read REST full (JSON output) web service using AFNetworking library in iOS/Objective C. Just visit codehelpdesk.blogspot
Comments
Post a Comment