I am building a project using story boards and a MasterView layout. I’m trying to get the UITableView data from a JSON file (http://afterimagedesign.tk/topHits.json I don’t know if this is correct JSON or not, I’m new) so I call these methods in viewDidLoad()
responseData = [[NSMutableData data] retain];
NSURLRequest *topHitsRequest = [NSURLRequest requestWithURL:[NSURLURLWithString:@"http://afterimagedesign.tk/topHits.json"]];
[[NSURLConnection alloc] initWithRequest:topHitsRequest delegate:self];
and then in connectionDidFinishLoading:(NSURLConnection *)connection method, I call this:
[connection release]
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];
NSDictionary *topHitsDictionary = [responseString JSONValue];
NSArray *topHitsArray = [topHitsDictionary valueForKey:@"title"];
The problem is (I think) that I get this error: “Instance method ‘-JSONValue’ not found.” I have looked for this for a while, and all of the tutorials I’ve seen use this method. Is it iOS 6 or something else? Thanks!
EDIT:
How do I add it to a UITableView? I tried cell.textLabel.text = [self.topKpop objectAtIndex:indexPath.row]; but I keep getting a SIGABRT error. I have gotten SIGABRT error, but this time it’s in the .m file.
I think the tutorials were using
SBJsonor similar JSON parser frameworks.If you don’t want to use any external frameworks, you can try
JSONObjectWithData:options:error:from theNSJSONSerializationclass, which is available since iOS 5.0.