iOS: If server database order changes, how to make my UITableView reflect it?

Multi tool use
iOS: If server database order changes, how to make my UITableView reflect it?
Currently, I have a UITableView
and load data from my database to my UITableView
like so.
UITableView
UITableView
- (void)getData {
// self.data is my UITableView data source
self.data = [Database getNumbers];
[self.tableView reloadData];
}
This works well for most part, however if the number order changes because of the server. It seems I have to call getData
method again.
getData
For example, if the the current order is 1,2,3,4,5 but the server changes number order to 1,4,2,3,5 I will have to update my database and then call getData
method.
getData
Is there a better solution? I hate having to retrieve the numbers from database all over again and reload the tableview. This seems like the best solution however and it does work.
I hope this makes sense. Ultimatly I am trying to keep the numbers in order with the server.
How does the device know the server-side data has been updated? Is there a property that you have on each item to know its order or is it just the order it comes in?
– atreat
Jul 2 at 2:23
When the user refreshes the device, they make an API request to see all the server data. The data order can be changed completly or just a little. I update the data in the local sql database so that way the App can work offline as well. I was hoping there some way I can reordered the data in UITableView to reflect my local database after my local database is updated.
– Curt Rand
Jul 2 at 4:20
1 Answer
1
I think that is necessary procedure when server data changed.
Even server can send only the change value, but it doesn't look like really good solution than reload all table. Because order can change all over the table right?.
Yes, the server can change either a little bit or a lot of the data all over the table.
– Curt Rand
Jul 2 at 0:28
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Your title mentions FMDB. You tagged this with SQLite. But your question refers to a server. A server implies a remote database. SQLite/FMDB is a local database. Please correct your question so it is clear.
– rmaddy
Jul 2 at 1:08