Moving cells from one table to another in iOS

I am trying to create an application with multiple table views that uses and implements master data. I would like the user to be able to select cells in one table and move them to another (for example, in the Apple mail application) using either a validation accessory or the selectedCell method with an action sheet. I am stuck because I don’t know if you really move the cell to another table, or if you add a copy to a new table and delete the original. Basically, I am asking for a fundamental example of cell movement to give me a push in the right direction.

+4
source share
2 answers

You will not move cells. The model for representing the table is an array. Move things between arrays and tell the tables that their model has changed.

id somePartOfMyModel = [self.arrayA objectAtIndex:someIndexPath.row]; [self.arrayA removeObject:somePartOfMyModel]; [self.arrayB addObject:somePartOfMyModel]; // the simplest, non-animated way to update the tables. // I'd advise getting this working first, then later trying fancier UI to indicate changes [self.tableViewA reloadData]; [self.tableViewB reloadData]; 
+4
source

You will not technically move the cell to another table. The way I would like to do this would be to pass the NSManagedObjectContextID element between the tables depending on how large your entities are and if the tables are in the same view controller.

0
source

All Articles