objective c - PrepareForSegue Tableview issue -
i have issue segue when clicking on cell , trying transfer date detailviewcontroller
i didn't find here answers question, asking here.
here method:
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { // nslog(@"source controller = %@", [segue sourceviewcontroller]); // nslog(@"destination controller = %@", [segue destinationviewcontroller]); // nslog(@"segue identifier = %@", [segue identifier]); nsindexpath *indexpath = [self.tableview indexpathforselectedrow]; if (indexpath){ lastnews *item = [news objectatindex:indexpath.row]; [segue.destinationviewcontroller setdetail:item]; nslog(@"%@", item.title); } } if remove if condition , leave code one:
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { // nslog(@"source controller = %@", [segue sourceviewcontroller]); // nslog(@"destination controller = %@", [segue destinationviewcontroller]); // nslog(@"segue identifier = %@", [segue identifier]); nsindexpath *indexpath = [self.tableview indexpathforselectedrow]; lastnews *item = [news objectatindex:indexpath.row]; [segue.destinationviewcontroller setdetail:item]; nslog(@"%@", item.title); } my data can transferred first cell.
if implement one:
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if ([[segue identifier] isequaltostring:@"detailnews"]) { nsindexpath *indexpath = [self.tableview indexpathforselectedrow]; //if (indexpath){ lastnews *item = [news objectatindex:indexpath.row]; [segue.destinationviewcontroller setdetail:item]; nslog(@"%@", item.category); } } it send title of news , first news. (nslog checking)
i know receives values, have checked nslog, not title.
for information have latest 20 news parsed web site that's working , cells filled news titles.
could please suggest me wrong?
thank you
if "sender" cell that's calling this, can do:
nsindexpath *indexpath = [[self tableview] indexpathforcell:sender]; lastnews *item = [news objectatindex:indexpath.row]; [segue.destinationviewcontroller setdetail:item];
Comments
Post a Comment