Skip to content

Instantly share code, notes, and snippets.

@Adam0101
Created May 19, 2011 16:18
Show Gist options
  • Save Adam0101/981156 to your computer and use it in GitHub Desktop.
Save Adam0101/981156 to your computer and use it in GitHub Desktop.
finishedTweets
// Once the data is complete, then we can parse it
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
// Store data blob we got back from twitter into a JSON string
NSString *jsonString = [[NSString alloc] initWithData:tweetBlob encoding:NSUTF8StringEncoding];
//Now use the Create a dictionary from the JSON string
NSDictionary *results = [jsonString JSONValue];
// Build an Array from the dictionary for easy access to each entry
NSDictionary *tweets = [results objectForKey:@"results"];
// Handle any errors that come from twitter in json, e.g. {"error":"page parameter out of range"}
if(tweets) {
NSDictionary *dictToBePassed = [NSDictionary dictionaryWithObject:tweets forKey:@"array"];
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter postNotificationName:@"twitterSearchDone"
object:nil
userInfo:dictToBePassed];
}
else {
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter postNotificationName:@"twitterFail"
object:nil
userInfo:nil];
}
[jsonString release];
jsonString = nil;
tweetBlob = nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment