- - (NSInteger)tableView:(UITableView *)tableViews numberOfRowsInSection:(NSInteger)section {
- return [tweetArray count];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableViews cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- static NSString *CellIdentifier = @"Cell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
- AGTweet *tweet = [tweetArray objectAtIndex:indexPath.row];
- cell.textLabel.text = [NSString stringWithFormat:@"@%@", [tweet trendName]];
- NSLog(@"%@", [tweet trendName]);
- }
- return cell;
- }
- // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- - (void)viewDidLoad {
- [super viewDidLoad];
- navBar.layer.contents = (id)[UIImage imageNamed:@"navBar.png"].CGImage;
- twitterEngine = [[MGTwitterEngine alloc] initWithDelegate:self];
- [twitterEngine setConsumerKey:kOAuthConsumerKey secret:kOAuthConsumerSecret];
- tweetArray = [[NSArray alloc] init];
- [self refreshTimeline];
- [self refreshButton];
- }
- - (void)searchResultsReceived:(NSArray *)searchResults forRequest:(NSString *)connectionIdentifier
- {
- tweetArray = [[NSMutableArray alloc] init];
- for(NSDictionary *d in searchResults) {
- NSLog(@"Dictionary: %@", d);
- AGTweet *tweet = [[AGTweet alloc] tweetDictionary:d];
- [tweetArray addObject:tweet];
- [tweet release];
- }
- [tableView reloadData];
- }
- - (void)requestSucceeded:(NSString *)connectionIdentifier
- {
- NSLog(@"Twitter request succeeded: %@", connectionIdentifier);
- }
- - (void)requestFailed:(NSString *)connectionIdentifier withError:(NSError *)error
- {
- NSLog(@"An error occured: %@", error);
- }
- - (void)refreshTimeline {
- [twitterEngine getCurrentTrends];
- [tableView reloadData];
- }
- /*
- // Override to allow orientations other than the default portrait orientation.
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- // Return YES for supported orientations
- return (interfaceOrientation == UIInterfaceOrientationPortrait);
- }
- */
- - (void)didReceiveMemoryWarning {
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
- // Release any cached data, images, etc that aren't in use.
- }
- - (void)viewDidUnload {
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
- }
- - (void)dealloc {
- [super dealloc];
- }
- @end