ios - Inserting objects from array into UITableView with other array -
i know how insert objects table using...
[self.tableview insertrowsatindexpaths:array withrowanimation:uitableviewrowanimationautomatic]; and how reload/delete/move rows using corresponding methods.
so, question...
i have array @[@"apple", @"banana", @"pear", @"strawberry"] in table , download new data in form of array...
@[@"orange", @"raspberry"]
how should insert these table order remains?
in end want this...
@[@"apple", @"banana", @"orange", @"pear", @"raspberry", @"strawberry"]
so, can't merge , sort arrays i'd lose indices of things have been inserted.
i don't want merge , reload data lose animations.
if instance iterate array , do...
//begin updates //insert object @"orange" @ index 2 //insert object @"raspberry" @ index 4 //end update then adjusted indices taken in consideration? i.e. if add them other way around @"raspberry" added @ index 3 not 4. table view work adjustment on fly?
you can take temp array in merge both array , sort .
then index of last added array object , using can make indexset , add row in table , add object in table datasource array.
may work you..
Comments
Post a Comment