Skip to content

Instantly share code, notes, and snippets.

@chrisabruce
Created September 30, 2009 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisabruce/198556 to your computer and use it in GitHub Desktop.
Save chrisabruce/198556 to your computer and use it in GitHub Desktop.
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];
//NSLog(responseString);
NSError *error;
SBJSON *json = [[SBJSON new] autorelease];
NSDictionary *feedData = [json objectWithString:responseString error:&error];
[responseString release];
//NSLog([feedData description]);
if (feedData == nil)
label.text = [NSString stringWithFormat:@"JSON Parsing failed: %@", [error localizedDescription]];
else {
NSArray *feedItems = [feedData objectForKey:@"game_session"];
NSMutableString *text = [[NSMutableString alloc] init];
for (int i = 0; i < [feedItems count]; i++) {
NSDictionary *item = [feedItems objectAtIndex:i];
[text appendFormat:@"%@ played %@\n", [item objectForKey:@"gamername"], [item objectForKey:@"game_name"]];
}
label.text = text;
[text release];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment