I know my request is formatted properly, but the response I get from the web service is not an NSDictionary.
- Why would it not be an NSDictionary?
-
How can I tell what kind of object “responseObject” is?
AFHTTPRequestOperation *operation = [[AFParseAPIClient sharedClient] HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) { if ([responseObject isKindOfClass:[NSDictionary class]]) { NSLog(@"Response for %@: %@", className, responseObject); [self writeJSONResponse:responseObject toDiskForClassWithName:className]; }else{ //NSLog(@"Response NOT NSDictionary: %@", [responseObject class]); NSString *str = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]; NSLog(@"str: %@", str); } } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Request for class %@ failed with error: %@", className, error); }];
Here’s what I get:
//Response NOT NSDictionary: <7b227265 73756c74 73223a5b 7b22636f ...>
EDIT: here’s what I get back:
str: {"results":[{"desc":"My description.","device_iPad":true,"device_iPhone":true,"createdAt":"2012-09-05T18:36:11.431Z","updatedAt":"2012-09-05T22:00:52.199Z"}]}
Would this be useful to you? It’s from AFNetworking github project
Give it a try, it’s pretty straightforward. *If it’s still an array do
[[JSON objectAtIndex:0] objectForKey@"desc /*(or whatever)*/"]