ios - using PFQueryTableViewController as detailviewController of UITableView -
i got uitableview 8 textlabel albumname(displaying array),now want use 'selected album name' parse class name(using initwithcoder method),and display corresponding class value should retrived parsetableview rows. did code:
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if ([segue.identifier isequaltostring:@"detailalbum"]) { nsindexpath *indexpath = [tableview indexpathforselectedrow]; myparsetableviewcontroller *detailscreen =segue.destinationviewcontroller; uitableviewcell *cell = (uitableviewcell *)[tableview cellforrowatindexpath:indexpath]; detailscreen.classname = cell.textlabel.text; nslog(@"selected label :%@",detailscreen.classname); } }
and in pfquerytableviewcontroller.h
@interface myparsetableviewcontroller : pfquerytableviewcontroller @property (nonatomic,strong) nsstring *classname; @end pfquerytableviewcontroller.m
- (id)initwithcoder:(nscoder *)acoder {
self = [super initwithcoder:acoder]; if (self) { self.parseclassname = self.classname;//showing null here nslog(@"parse class name1%@",self.parseclassname); self.textkey = @"songtitle"; self.pulltorefreshenabled = yes; self.paginationenabled = no; } return self; }
when run,i this: selected label : xyz <-----getting class name here,then why not passing parse classname parse class name1(null)<--------
query:
* terminating app due uncaught exception 'nsinvalidargumentexception', reason: '* setobjectforkey: object cannot nil (key: classname)' * first throw call stack:
the reason why app crashing because trying insert nil value nsarray or nsdictionary. instead, need insert [nsnull null].
now, nslog(@"parse class name1%@",self.parseclassname); printing self.parseclassname null because self.classname nil
-initwithcoder: first method called, , object hasn't been instantiated yet. means self.classname return nil. retrieve value coded object, need like:
self.parseclassname = [adecoder decodeobjectforkey:@"classname"];
Comments
Post a Comment