I'm using Objective-C and AFNetworking. I made a post request and it will retu a JSON string. I can get an NSDictionary like this:{msg="...", result="..."}, or an NSArray like this:{{id=1, content="..."},{id=2,content="..."}...}. So here's the thing: further tasks I need to do will differ according to the JSON String I get.
How do I make the code tell whether the type of the JSON string is NSArray or NSDictionary?
Here is my code:
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
[manager POST:url parameters:parameter progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
if (responseObject is an NSDictionary){
//do something
}
else{
//do something
}
}failure:^(NSURLSessionDataTask *task, NSError *error) {
NSLog(@"Error: %@", error);
}];
Thanks in advance!
