0

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.

Illep
  • 16,375
  • 46
  • 171
  • 302

1 Answers1

1

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

CarlJ
  • 9,461
  • 3
  • 33
  • 47
  • Thank you loads for your reply, but can you please tell me what is `self responseData` ? `objectFromJSONData` has to be a JSONKit method i guess. Am i correct ? – Illep Jan 23 '12 at 16:36
  • your MKNetworkOperation Object has a Method responseData which is the data from the request. Please read the doc/manuals from https://github.com/MugunthKumar/MKNetworkKit/blob/master/MKNetworkKit/MKNetworkOperation.h – CarlJ Jan 24 '12 at 16:47
  • I took your advice, now i am using ASIHTTPRequest. – Illep Jan 24 '12 at 16:52
  • 5
    meccan - Can you give some reasons for why you think future projects should use ASIHTTPRequest? According to their webpage -> http://allseeing-i.com/[request_release]; they are no longer developing/supporting it. That is why I went with MKNetworkKit in a few of my new projects. – Mark Norgren Feb 07 '12 at 18:41
  • 1
    @marked atm ASIHTTPRequest is the best sdk for URL Connection other like AFNetwork and so on, should improve some usability. At my opinion i stick at ASIHTTPRequest until, i get a better solution... And the last commit on github is from "January 22, 2012" – CarlJ Feb 08 '12 at 12:58
  • The reason I wrote MKNetworkKit was to make it as easy to use like ASI and be powerful. MKNetworkKit's core strength is probably built in caching, ARC compatible and easy of use. – Mugunth Mar 04 '12 at 15:18
  • 3
    after one project with MKNetworkKit and dozens with ASIHTTPRequest i would never go back to ASIHTTPRequest... MKNetworkKit rulez – Peter Lapisu Jul 11 '12 at 13:58