ios - Incorrect order of cells in UITableVIew objective-c -


i've got problem while filling tableview cells.

there's array, should cells initiated

items = [nsmutabledictionary dictionarywithobjectsandkeys:              @"http://feeds.test.com/home", @"home",              @"http://feeds.test.com/publications", @"refcardz , guides",              @"http://feeds.test.com/agile", @"agile zone",              @"http://feeds.test.com/big-data", @"big data zone",              @"http://feeds.test.com/cloud", @"cloud zone",              @"http://feeds.test.com/database", @"database zone",              @"http://feeds.test.com/devops", @"devops zone",              @"http://feeds.test.com/integration", @"integration zone",              @"http://feeds.test.com/iot", @"iot zone",              @"http://feeds.test.com/java", @"java zone",              @"http://feeds.test.com/mobile", @"mobile zone",              @"http://feeds.test.com/performance", @"performance zone",              @"http://feeds.test.com/webdev", @"web dev zone",              nil]; 

so order of created cells should this:

home - refcardz , guides - agile zone - big data zone - cloud zone - database zone - devops zone - integration zone - iot zone - java zone - mobile zone - performance zone - web dev zone

but cells ordered in way enter image description here

here's cellforrowatindexpath, if helps:

- (uitableviewcell *)tableview:(uitableview *)sourcetableview cellforrowatindexpath:(nsindexpath *)indexpath {     nsstring *myidentifier = @"cell";     uitableviewcell *cell = [sourcetableview dequeuereusablecellwithidentifier:myidentifier forindexpath:indexpath];      nsstring *curname = [websitesnames objectatindex:indexpath.row];     cell.textlabel.text = [curname copy];     if([self.cellselected containsobject:indexpath]){         cell.accessorytype = uitableviewcellaccessorycheckmark;     }     else{         cell.accessorytype = uitableviewcellaccessorynone;     }     return cell; } 

i have no idea why there's such kind of strange behavior. how improve code view cells in order in array?

you using dictionary , dictionary not ordered collection. have use array instead. convert items array instead.

another option add level of dictionary existing dictionary , use keys such "0", "1", "2"...etc

e.g. items = [nsmutabledictionary dictionarywithobjectsandkeys:@{@"url":@"http://feeds.test.com/home", @"title":@"home"}, @"0", @"url":@"http://feeds.test.com/publications", @"title":@"refcardz , guides"}, @"1".....

basically use index key dictionary , value dictionary url , title keys.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -