objective c - Can't set Custom UITableViewCell property - iOS -


first of want apologize bad english.

i'm having trouble set properties of custom uitableviewcell (historicocell).

when try set property of cell get: signal sigabrt error:

-(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { // dequeue cell.  historicocell *cell = (historicocell *)[self.tblhistorico dequeuereusablecellwithidentifier:@"cellidentifier" forindexpath:indexpath];  // fetch item nsdictionary *item = [self.dbmanager.arrcolumnnames objectatindex:indexpath.row];  // configure table view cell [cell.lblcodigo settext:[nsstring stringwithformat:@"%@", item[@"codigo"]]]; [cell.btnfavoritar addtarget:self action:@selector(didtapbutton:) forcontrolevents:uicontroleventtouchupinside];  return cell; 

}

i followed lot of tutorials , questions on web stil error.

can me?

my code:

historicocell.h

#import <uikit/uikit.h>  @interface historicocell : uitableviewcell  @property (weak, nonatomic) iboutlet uilabel *lblcodigo; @property (weak, nonatomic) iboutlet uibutton *btnfavoritar;  @end 

secondviewcontroller.h

    #import <uikit/uikit.h>  @interface secondviewcontroller : uiviewcontroller <uitableviewdatasource, uitableviewdelegate>  @property (weak, nonatomic) iboutlet uitableview *tblhistorico; 

secondviewcontroller.m

    #import "secondviewcontroller.h" #import "dbmanager.h" #import "historicocell.h"  @interface secondviewcontroller ()  @property (nonatomic, strong) dbmanager *dbmanager;  @property (nonatomic, strong) nsarray *arrpeopleinfo;  -(void)loaddata;   @end  @implementation secondviewcontroller  static nsstring *cellidentifier = @"cellidentifier";  - (void)viewdidload {     [super viewdidload];     // additional setup after loading view, typically nib.      // make self delegate , datasource of table view.     self.tblhistorico.delegate = self;     self.tblhistorico.datasource = self;      // initialize dbmanager property.     self.dbmanager = [[dbmanager alloc] initwithdatabasefilename:@"bernoullidb.sql"];     [self.tblhistorico registerclass:[historicocell class] forcellreuseidentifier:@"cellidentifier"];     [self loaddata]; }  - (void)didreceivememorywarning {     [super didreceivememorywarning];     // dispose of resources can recreated. }  -(void)loaddata{     // form query.     nsstring *query = @"select * tbhistorico";      // results.     if (self.arrpeopleinfo != nil) {         self.arrpeopleinfo = nil;     }     self.arrpeopleinfo = [[nsarray alloc] initwitharray:[self.dbmanager loaddatafromdb:query]];      // reload table view.     //[self.tblhistorico reloaddata]; }  -(nsinteger)numberofsectionsintableview:(uitableview *)tableview{     return 1; }   -(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section{     return self.arrpeopleinfo.count; }   -(cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath{     return 60.0; }  -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     // dequeue cell.      historicocell *cell = (historicocell *)[self.tblhistorico dequeuereusablecellwithidentifier:@"cellidentifier" forindexpath:indexpath];      // fetch item     nsdictionary *item = [self.dbmanager.arrcolumnnames objectatindex:indexpath.row];      // configure table view cell     [cell.lblcodigo settext:[nsstring stringwithformat:@"%@", item[@"codigo"]]];     [cell.btnfavoritar addtarget:self action:@selector(didtapbutton:) forcontrolevents:uicontroleventtouchupinside];      return cell; }  - (void)didtapbutton:(id)sender {     nslog(@"%s", __pretty_function__); }  @end 

you should set cell indentifier "cellidentifier" cell in file inspector

or register nib file if add cell nib:

uinib *itemnib = [uinib nibwithnibname:@"yourcell" bundle:nil]; [self.tableview registernib:itemnib forcellreuseidentifier:@"yourcellreuseindentifier"]; 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -