ios - Objective C error [__NSCFNumber length]: unrecognized selector sent to instance -
i m writing tableview based application. works when use default cells in tableview. when try make customs cells have error :
2014-12-01 22:50:01.690 signaturegourmande[15701:624637] -[__nscfnumber length]: unrecognized selector sent instance 0xb0000000000000c3 2014-12-01 22:50:01.716 signaturegourmande[15701:624637] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscfnumber length]: unrecognized selector sent instance 0xb0000000000000c3'
the application works when have code :
static nsstring *simpletableidentifier = @"simpletableitem"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:simpletableidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:simpletableidentifier]; } cell.textlabel.text = [nomdata objectatindex:indexpath.row]; return cell;
i have error when replace code :
static nsstring *simpletableidentifier = @"produitcell"; produitcell *cell = (produitcell *)[tableview dequeuereusablecellwithidentifier:simpletableidentifier]; if (cell == nil) { nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"produitcell" owner:self options:nil]; cell = [nib objectatindex:0]; } cell.namelabel.text = [nomdata objectatindex:indexpath.row]; cell.thumbnailimageview.image = [uiimage imagenamed:[urldata objectatindex:indexpath.row]]; cell.pricelabel.text = [prixdata objectatindex:indexpath.row]; return cell;
i have created class "produitcell" ".h" , ".m", have 3 property in .h file. have linked these property in storyboard right cells items in xib.
thanks help.
check below line, if nsnumber
class type change below using stringvalue:-
cell.pricelabel.text = [[prixdata objectatindex:indexpath.row]stringvalue];
Comments
Post a Comment