Wednesday, 15 July 2015

xcode - Dynamic sections with dynamic cells with Core Data? -



xcode - Dynamic sections with dynamic cells with Core Data? -

i close solution, cannot figure out rest, asking help now... utilize core data, i'd show, whats within of it. here code far:

at .m

@property nsmutablearray *users, *sharedwishes; - (void)viewdidload { [super viewdidload]; appdelegate *delegate=[uiapplication sharedapplication].delegate; self.context=delegate.managedobjectcontext; self.users=delegate.collectusernames; //collect every users database self.sharedwishes=[delegate collectsharedwishes]; //collect every wish db - each user has different number of records [self.tableview reloaddata]; } - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { // works great far homecoming self.users.count; } -(nsstring*)tableview:(uitableview *)tableview titleforheaderinsection:(nsinteger)section { user *user=[self.users objectatindex:section]; //shows username each section if(self.users.count<1) homecoming @"no friends"; else homecoming user.username; //this fine, } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { sharedwishes *wish=[self.sharedwishes objectatindex:indexpath.row]; //this problem is...the tableview shows records until other user records starts static nsstring *identifier=@"cell"; cell *cell = [tableview dequeuereusablecellwithidentifier:identifier forindexpath:indexpath]; ... }

so, suggestion cellforrowatindexpath:, should add? every section should have title (which has) current user name, , every section should contain particular person's records (which fails). instead, when new section begins (with new user) existing records starting repeat. how should avoid it? in advance!

edit: added few line cellforrowatindexpath: user *user=[self.users objectatindex:indexpath.section]; appdelegate *delegate=[uiapplication sharedapplication].delegate; self.currentuserwishes=[delegate collectcurrentusersharedwishes:user];

now works!

xcode uitableview core-data

No comments:

Post a Comment