MKNetwork saving JSON content to NSDictionary

2.5k views Asked by At

I am using MKNetwork, to handle the Networking functionality of my application.

I am trying to read a JSON file, and save its content to a NSDictionary.

NSDictionary *valueDic = [[completedOperation responseJSON] objectForKey:@"value"];

The above code (responseJSON)works for iOS 5 and above. i need it to work for iOS 4 too. The author of this framework says the following; (see the comments section in this post)

Subclass MKNO and override that method and call
[super responseJSON] for iOS5 and return JSONKit(or equivalent) based dictionary for other versions

I have no clue how to implement this, Can someone please help me. I have been stuck in this the whole day.

1

There are 1 answers

7
CarlJ On BEST ANSWER

Create a custom subclass of the MKNO an implement the responseJSON Method like:

- (NSDictionary *) responseJSON {
 return [ [self responseData] objectFromJSONData];
}

Don't forget to include "JSONKit.h"

PS: For future projects you should use: ASIHTTPRequest