I have a pretty simple MVC design question.
I have a class with many properties and a form to represent an instance of the class. Some of the properties of the class are arrays - some of them are arrays of NSStrings, which must be represented in the one-dimensional representation of the table, and some are arrays of sub-objects that must be represented in the two-dimensional representation of the table (one column for the properties of each object). I actually don't want to do anything with the data in any of these tables - just present the contents in a scrollable table view in read-only form.
During the first bind attempt, I added an object controller associated with the class instance. Then I tried to bind each column of each type of table to the class "select" element with a model key path that defines the property of the instance array (and for two-dimensional tables, a member of a sub-object). I was surprised that this does not work for columns of one-dimensional tables.
Then I added one array controller for each table, binding it to the "select" element of the object controller. For one-dimensional tables, I bound a column to an array controller without a model key path; for two-dimensional tables, I bound the column to the array controller using the model key path that defines the property of the sub-object. This works, but for a window with seven tables, I have seven array controllers! This is like brute force, as tables do nothing but represent data.
My question is simple: my project follows good MVC practice - do I really need all of these array controllers? Or is there an easier way to specify my bindings (for one-dimensional and / or two-dimensional tables) that will allow me to eliminate some array controllers? When I have an array of rows in an object that will be displayed in a table with a single column, it feels that the excessive use of the array controller is related to the object and the table.
As a side question - do I really need to worry about excessive array controllers? Are they lightweight objects that I should use as liberal or resource-intensive objects that I have to save, especially in limited resource contexts like iOS?
source share