I have a table view that loads information from the web, and displays it in custom cells. In these custom cells I have a button that I assigned through storyboard.
If this button is pressed, it triggers a method (defined in the cellForRowAtIndexPath method)
cell.viewArticleButton.action = @selector(viewArticle:);
It is in this method that I am having trouble. The action works except that it doesn't use the link provided for each respective cell (the link at each index path) instead it uses only the first row's link, regardless of what row I tap.
-(IBAction)viewArticle:(id)sender {
NSLog(@"View Article Button Tapped");
NewsCell *cell = (NewsCell *)[self.tableView dequeueReusableCellWithIdentifier:@"NewsCell"];
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
MWFeedItem *item = [itemsToDisplay objectAtIndex:indexPath.row];
// Open link from item.link
}
Any help would be appreciated. I have a feeling that it is this line that isn't doing what I want:
NewsCell *cell = (NewsCell *)[self.tableView dequeueReusableCellWithIdentifier:@"NewsCell"];