I am using the the STTwitter API to make an App only twitter Feed. I have successfully output the tweet to the table cell, but now I'm attempting to connect user profile images and I am running in to some problems. I tried implementing the code I found here, but I was getting an error stating "No known class method for selector 'imageWithContentsOfURL:'" so I fixed the problem by replacing UIImage with CIImage. However, now my app is crashing because I'm trying to output a CIImage to an UIImageView. My code and errors are as follows:
Code:
- (void)viewDidLoad
{
[super viewDidLoad];
NSString* boldFontName = @"Avenir-Black";
[self styleNavigationBarWithFontName:boldFontName];
self.title = @"Twitter Feed";
self.feedTableView.dataSource = self;
self.feedTableView.delegate = self;
self.feedTableView.backgroundColor = [UIColor whiteColor];
self.feedTableView.separatorColor = [UIColor colorWithWhite:0.9 alpha:0.6];
//self.profileImages = [NSArray arrayWithObjects:@"profile.jpg", @"profile-1.jpg", @"profile-2.jpg", @"profile-3.jpg", nil];
STTwitterAPI *twitter = [STTwitterAPI twitterAPIAppOnlyWithConsumerKey:@"stuff"
consumerSecret:@"stuff"];
[twitter verifyCredentialsWithSuccessBlock:^(NSString *username) {
[twitter getUserTimelineWithScreenName:@"RileyVLloyd"
successBlock:^(NSArray *statuses) {
self.twitterDataSource = [NSMutableArray arrayWithArray:statuses];
for (int i=1; i <= _twitterDataSource.count; i++) {
NSLog(@"%d", i);
NSDictionary *tweetDictionary = self.twitterDataSource[i];
NSString *final = tweetDictionary[@"profile_image_url"];
NSLog(@"%@", final);
}
[self.feedTableView reloadData];
} errorBlock:^(NSError *error) {
NSLog(@"%@", error.debugDescription);
}];
} errorBlock:^(NSError *error) {
NSLog(@"%@", error.debugDescription);
}];
//[self getTimeLine];
}
#pragma mark Table View Methods
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.twitterDataSource.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"FeedCell3" ;
FeedCell3 *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[FeedCell3 alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
cell.nameLabel.text = @"RileyVLloyd";
cell.likeCountLabel.text = @"293 likes";
cell.commentCountLabel.text = @"55 comments";
//NSString* profileImageName = self.profileImage[indexPath.row%self.profileImage.count];
cell.profileImageView.image = _profileImage;
NSInteger idx = indexPath.row;
NSDictionary *t = self.twitterDataSource[idx];
cell.updateLabel.text = t[@"text"];
cell.dateLabel.text = @"1 day ago";
return cell;
}