When building a view for an iPhone app, one must consider how variable data will be determined by the view. Two design options jump readily to mind:
NSArray
of itemsdataSource
property, which implements a protocol and returns the items.The former is used by views such as UITabBar
, while the latter is used by UITableView
. What are the pros and cons of these options? Is there a reason for the two distinct paradigms, or is one universally superior?
It's mostly about the amount of data and limited amount of memory in relation to simplicity.
Simpler is always better if you can get away with it. A tab bar probably have less than 10 items which is no problem to hold in memory at once so the simplest solution is the best.
A table view however may have thousands of rows that may contain expensive data like images. Therefor it has a more complex design to be able to keep only the necessary data in memory.