For this purpose you can use segue. First you need to create a segue to your destination view controller in your storyboard. Give an identifier for this segue .Then implement these methods in your controller
#pragma mark - Navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
if ([segue.identifier isEqualToString:SEGUE_IDENTIFIER]) {
DestinationController *dest = (DestinationController *)[segue destinationViewController];
//here you can pass the data
dest.wishLabel.text = wish.wishlistItem;
dest.descriptionTextView.text = wish.descWishItem;
dest.detailTargetDate.text = wish.targetDate;
// or you can pass the entire wish object
dest.wish = wish;
}
}
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
{
return NO;
}
You need to go to the destination view controller only when user select a cell. That's why we return NO in the second delegate method. Now implement didSelectRowAtIndexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == ROW_INDEX {
[self performSegueWithIdentifier:SEGUE_IDENTIFIER sender:self];
wish = [self.wishlistItem objectAtIndex:indexPath.row];
}
}
Here, performSegueWithIdentifier is used for navigation