this is the json string that i am receiving from the API:
"incentives_and_benefits" = "{\"food\":{\"0\":\"\"},\"commission\":{\"0\":\"\"},\"uniform\":{\"0\":\"\"},\"transport\":{\"0\":\"\"},\"extras\":{\"0\":\"\"}}";
and i assigned it to dictionary. Now I need to get the values inside the dictionary. I tried using the solution given here: How to get values from dict
Heres what I have so far:
NSString *strIncentives = [[self.jobDetailDict objectForKey:@"sub_slots"] objectForKey:@"incentives_and_benefits"];
NSData *jsonData = [strIncentives dataUsingEncoding:NSUTF8StringEncoding];
NSError *e;
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData options:nil error:&e];
NSLog(@"DICT: %@", dict);
NSString *food = [dict objectForKey:@"food"];
NSLog(@"DICT: %@", food);
NSString *commission = [dict objectForKey:@"commission"];
NSLog(@"DICT: %@", commission);
NSString *uniform = [dict objectForKey:@"uniform"];
NSLog(@"DICT: %@", uniform);
NSString *transport = [dict objectForKey:@"transport"];
NSLog(@"DICT: %@", transport);
NSString *extras = [dict objectForKey:@"extras"];
NSLog(@"DICT: %@", extras);
Now I need to check whether food's value is 0 or 1..When Food's value is 1 then i need to get Hello string and display it. (this is just an example) food: {"1":"Hello"}
if([food isEqualToString:@""])
{
//the string will be placed here
NSLog(@"FOOD Available")
}
when i reach the if statement i get an error:
[__NSCFDictionary isEqualToString:]: unrecognized selector sent to instance
How will i be able to resolve this? please help and thank you in advance.