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)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex | |
{ | |
if (buttonIndex == 1) { | |
NSLog(@"Username:%@",[[alertView textFieldAtIndex:0] text]); | |
NSLog(@"Password:%@",[[alertView textFieldAtIndex:1] text]); | |
} | |
} |
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)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex | |
{ | |
if (buttonIndex == 1) | |
NSLog(@"TextField contents:%@",[[alertView textFieldAtIndex:0] text]); | |
} | |
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
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView | |
{ | |
// Return the number of sections. | |
return 1; | |
} | |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | |
{ | |
// Return the number of rows in the section. | |
return [[self tweets]count]; |
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]; | |
} |
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
#import <UIKit/UIKit.h> | |
@interface SearchResults : UITableViewController { | |
NSMutableArray *tweets; | |
} | |
@property (nonatomic, retain) NSMutableArray *tweets; | |
@end |
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
#import "SimpleTwitterSearchViewController.h" | |
#import "SearchTwitter.h" | |
@implementation SimpleTwitterSearchViewController | |
- (void)dealloc | |
{ | |
[searchTheTweets release]; | |
[super dealloc]; |
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
#import <UIKit/UIKit.h> | |
#import "SearchTwitter.h" | |
#import "SearchResults.h" | |
@interface SimpleTwitterSearchViewController : UIViewController { | |
SearchTwitter *searchTheTweets; | |
IBOutlet UIButton *searchButton; | |
IBOutlet UITextField *searchTerm; | |
} |
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 |
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
// Gather up all the asynch data as it comes in and store it in the blob | |
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { | |
// Check to see if this is a new search, if so it will be nil, so create an object | |
if(tweetBlob == nil) { | |
tweetBlob = [[NSMutableData alloc]init]; | |
[tweetBlob appendData:data]; | |
} | |
else { | |
[tweetBlob appendData:data]; |
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
//Setup and start async download | |
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; | |
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; | |
[connection release]; | |
[request release]; |
NewerOlder