ios - Unable to get subclassed UITableViewCells to display data from successfully queried Parse objects -


this question has been answered; thank jsksma2.

i cannot data fill rows in tableview, though data , can hard-code tableview display static amount of dummy text. have hunch issue relates initwithstyle vs initwithcoder subclassed uitableviewcells.

in subclass of uitableviewcontroller called "giveitemstableviewc", during viewdidload querying parse objects each called "pfgiveitem". these , add each 1 global variable, mutable array called "mygiveitems". log these, , looking for, part working.

giveitemstableviewcontroller

- (void)viewdidload {     [super viewdidload];     pfquery *query = [pfquery querywithclassname:@"giveitem"];     [query wherekey:@"giver" equalto:[pfuser currentuser]];     [query findobjectsinbackgroundwithblock:^(nsarray *objects, nserror *error) {         if (!error) {             self.mygiveitems = [[nsmutablearray alloc]init];             (pfobject *object in objects) {                 pfgiveitem *newgiveitem = [[pfgiveitem alloc]init];                 newgiveitem.giveitemname = object[@"giveitemtitle"];                 newgiveitem.giveitemimage = object[@"giveitemphoto"];                 [self.mygiveitems addobject:newgiveitem];             }         } else {             // log details of failure             nslog(@"error: %@ %@", error, [error userinfo]);         }      }]; } 

now trying load each 1 of these giveitems tableview object, using custom tableviewcells each called "giveitemcell."

giveitemcell.m

@implementation jfgiveitemcell    @synthesize giveitemimageview = _giveitemimageview; @synthesize giveitemlabel = _giveitemlabel;   - (id)initwithstyle:(uitableviewcellstyle)style reuseidentifier:(nsstring *)reuseidentifier {     self = [super initwithstyle:style reuseidentifier:reuseidentifier];     if (self) {         // initialization code     }     return self; } 

back in table view controller, return 1 section table view. , when include static number rowsinsection, can output test values each cell. if execute code below, tableview cells label of "test", per upcoming cellforrowatindexpath method. works test, i'm looking dynamically load proper information.

giveitemstableviewcontroller

- (nsinteger)numberofsectionsintableview:(uitableview *)tableview {     return 1; }  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     return 4; }   - (jfgiveitemcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {      static nsstring *cellidentifier = @"cell";      jfgiveitemcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];     if (cell == nil){         cell = [[jfgiveitemcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifier];     }      //    pfgiveitem *giveitem = self.mygiveitems[indexpath.row];     //    cell.giveitemlabel.text = giveitem.giveitemname;     cell.giveitemlabel.text = @"test";     return cell; } 

it looks you're forgetting call [tableview reloaddata] in callback of block method:

- (void)viewdidload {     [super viewdidload];     pfquery *query = [pfquery querywithclassname:@"giveitem"];     [query wherekey:@"giver" equalto:[pfuser currentuser]];     [query findobjectsinbackgroundwithblock:^(nsarray *objects, nserror *error) {         if (!error) {             self.mygiveitems = [[nsmutablearray alloc]init];             (pfobject *object in objects) {                 pfgiveitem *newgiveitem = [[pfgiveitem alloc]init];                 newgiveitem.giveitemname = object[@"giveitemtitle"];                 newgiveitem.giveitemimage = object[@"giveitemphoto"];                 [self.mygiveitems addobject:newgiveitem];             }             [self.tableview reloaddata];         } else {             // log details of failure             nslog(@"error: %@ %@", error, [error userinfo]);         }      }]; } 

also, second @crimsonchris in saying need set datasource methods properly:

- (nsinteger)numberofsectionsintableview:(uitableview *)tableview {   return self.mygiveitems.count } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -