So basically I have a JSON feed that returns a boolean if there is no event but if there is an event it returns an object.
No event example:
{"event":false,"status":"success"}
Event example:
{"event":
{..."somevar":"somevalue"...},
"status":"success"}
If it is the case there is an event I can happily store it to an NSDictionary and get keypair values.
If it is the case that there is no event it crashes saying that its a boolean and it cant look for objectForKey if its a boolean.
How do I check to see if it is a boolean or not?
Something is missing here – if you use NSJSONSerialization you will get a tree of objects back – the object for “event” will be a NSNumber if ‘false’ and a dictionary if a real event. So what you need to do is test the class of the objectForKey:@”event”, and only try to drill down if it passes ‘isKindOf:[NSDictionary class]’.