Created
May 19, 2011 16:18
-
-
Save Adam0101/981156 to your computer and use it in GitHub Desktop.
finishedTweets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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