Best way to re-use a UITableView with dynamic data?

My application has a series of table views based on some hierarchical data. For example, the user selects "Browse by XYZ" on my CategoryListController, and then I load my DocumentListController based on that selection.

Right now I'm getting the list through a web service that returns some JSON data, but that's beside the point. I could retrieve this dynamic list from a SQLite database, and I would have the same underlying challenge.

The problem here is that since the list of items for my table view in DocumentListController will change depending on which selection the user tapped on, I have to load my list after the table view is displayed.

Right now I'm using -viewWillAppear: to trigger this "refresh" of the data items from my web service. I was wondering if this is the best way to be doing this refresh, or if I should look into using a different method. I tried using -viewDidLoad but that method gets called only once for the DocumentListController, and I have to check at every invocation if the "selection" has changed, and if so, I need to call my web service again.

What's the best way to do something like this?

Answers


Since you retrieve the data through the network, I would suggest to post a notification after you process it. Your DocumentListController should register for that notification and invoke its table view's reloadData in the notification handler.

Another approach, if the data will always be there when displaying the view, is what you've suggested - update table view in viewWillAppear.


Need Your Help

Bytecode manipulation manifest entries

java instrumentation bytecode-manipulation javaagents

I'm having fun doing some Java bytecode modification tutorials. All of them state that I need to have the following manifest attirbutes set:

UIButton does not scroll when adding to UIScrollView

ios objective-c autolayout

I have added a UIButton, and a UILabel to a UIScrollView. I added two constraints to the button using Auto Layout, and none to the label. I can see label moving on the screen, however I do not se...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.