in xcode (ios) populate tableview information received of url
myobject = [[nsmutablearray alloc] init]; nsstring *url_json = @"http://localhost/info.php"; nsdata *jsonsource = [nsdata datawithcontentsofurl: [nsurl urlwithstring:url_json]]; id jsonobjects = [nsjsonserialization jsonobjectwithdata: jsonsource options:nsjsonreadingmutablecontainers error:nil]; (nsdictionary *datadict in jsonobjects) { nsstring *id_data = [datadict objectforkey:@"my_id"]; nsstring *title_data = [datadict objectforkey:@"my_title"]; nsstring *thumbnail_data = [datadict objectforkey:@"my_icon"]; dictionarya = [nsdictionary dictionarywithobjectsandkeys: id_data, my_id, title_data, my_title, thumbnail_data, my_icon, nil]; [myobject addobject:dictionarya]; }
what second table view receive real id (coming url , passed myobject) of clicked row , not indexpath id sent (objectatindex:indexpath.row) when using following:
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if([segue.identifier isequaltostring:@"showsecond"]){ nsindexpath *indexpath = [self.tableview indexpathforselectedrow]; secondviewcontroller *list = segue.destinationviewcontroller; list.myinfo = [myobjectcat objectatindex:indexpath.row]; } }
any ideas on how can achieve that?
thanks
you can -
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if([segue.identifier isequaltostring:@"showsecond"]){ nsindexpath *indexpath = [self.tableview indexpathforselectedrow]; secondviewcontroller *list = segue.destinationviewcontroller; nsdictionary *dict = [myobjectcat objectatindex:indexpath.row]; list.info = [dict objectforkey@"my_id"];//passing real id } }