I have a UITableViewController, I have 4 types of tabular data to present in the same format. Is it better to use one UITableViewController and reload data each time I need to present data, or should I create four UITableViewController instances with its own data source?
Points I considered (which I’m not sure if true):
-
I could save resources by reusing one instance of UITableViewController.
-
However, always calling UITableView’s reloadData before presenting the grid might have impact on performance.
What is the best approach in terms of performance / memory consumption / best practice? Or is there no difference? Hope I am clear.
Update: To be exact, I have popover controllers with a table. I use it to as a “Selection Screen” for various fields in my screens.
The number of fields needing the popover are dynamic, so there can be 4 in one screen or upto 10 in another screen. The dilemma is should I create multiple instances of selection popover (one per field), or should I just use one selection screen and reload the data per field?
Short answer :
It doesn’t really matter unless your data sets are massive (thousands of rows). Whatever is easiest for you is fine!
Long answer :
I would have a different one per data type – it’s probably going to be a slightly more responsive ui if you do (as you pointed out, this comes at the cost of more memory usage).
However, I would use delayed instantiation i.e. only create them the first time they are asked for.
I would also release them if I received a low memory warning notification and they weren’t visible.