Created
May 19, 2011 16:40
-
-
Save Adam0101/981198 to your computer and use it in GitHub Desktop.
notificationsTweetResults
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
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Setup NSNotification center to listen for response back from Asynch twitter search | |
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; | |
// Listen for call to twitterSearchDone, and then run function recvTwitterResults | |
[nc addObserver:self selector:@selector(recvTwitterResults:) name:@"twitterSearchDone" object:nil]; | |
[nc addObserver:self selector:@selector(twitterError:) name:@"twitterFail" object:nil]; | |
} | |
// Get notification from SearchTwitter, that the array of urls | |
// matching the search term and our dictionary of tweets | |
- (void)recvTwitterResults:(NSNotification *)notification { | |
if([notification userInfo]==nil){ | |
UIAlertView *twitterViewAlertView = [[UIAlertView alloc] initWithTitle:@"Twitter Search" | |
message:@"No Results Found" | |
delegate:self | |
cancelButtonTitle:@"Try Again" | |
otherButtonTitles:@"Cancel",nil]; | |
[twitterViewAlertView show]; | |
[twitterViewAlertView release]; | |
} | |
else { | |
// Unpack the passed dictionary from nsnotifications | |
NSDictionary *unpackDict = [notification userInfo]; | |
// Take out the array with links | |
[self setTweets:[unpackDict objectForKey:@"array"]]; | |
[[self tableView]reloadData]; | |
} | |
} | |
- (void)twitterError:(NSNotification *)notification { | |
UIAlertView *twitterViewAlertView = [[UIAlertView alloc] initWithTitle:@"Twitter Search" | |
message:@"Twitter search failed" | |
delegate:self | |
cancelButtonTitle:@"Try Again" | |
otherButtonTitles:@"Cancel",nil]; | |
[twitterViewAlertView show]; | |
[twitterViewAlertView release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment