What does UITableView's "deleteRowsAtIndexPaths: withRowAnimation:" method do?
******** Add question **********
If the table view does not affect the model: Is the pointer path of the screen cells changed to reflect their actual position OR are the indexes of the deleted cells invisible until reloadData is called?
******* Original question **********
I know it marks the cells for deletion and animates the deletion, but what does it do with the model?
Does this affect the model at all (I can't imagine what it does)?
Are the cells "still there" but invisible?
When the user starts scrolling, is he skipping the delegate calls for remote indexes?
Are there any updates to the model?
Looks like I've read so far ...
a source to share
- (void) deleteRowsAtIndexPaths: (NSArray *) indexPaths withRowAnimation: (UITableViewRowAnimation) animation;
Removes rows from tableView. It doesn't change your model at all. You have to do it yourself. The cells are removed, but if you call reloadData before removing the row from your model. The cell will reappear.
So, yes, it expects you to update your model.
a source to share
UITableView is a VIEW that UIKit is heavily MVC based. You are responsible for updating the model. Infact, your controller will probably call (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
in response to an observation (or notification) of your model change.
For example, let's say the UI has "remove 10 random items". The correct flow for this is:
- view - pressing user button
- controller - gets the update button for update models Controller
- - observes a change in the model
- view the list of updates
While this seems a bit contrived - why not pretend to just update the list and tell the model? this will make bette rcode easier to understand and work better with UIKit. This design, for example, does not assume that controller in 2 and 3 is the same controller, so you have more flexibility.
I usually use YAGNI for design, but I believe that the strong focus of MVC os UIKit means that YAGNT (you are going to ...)
a source to share