I just wanted to make it clear that by "design" I mean software design, not user interface design.
I have an application similar to my own settings application. The problem I am facing is that it does not match the same MVC style. Other applications tend to focus around displaying one kind of thing. For example, in the case of an application with a table table, these are elements. Elements explicitly contain a model, and they have similar properties and behavior, that is, they can be displayed and interact in the same way. An application like this almost designs itself!
My application, like the settings application, consists of an arbitrary selection of rows displaying dissimilar data in different ways. One line may contain a switch, and the other may have a very specific look when clicked. They are all very different.
How do you create something like this?
Currently, I am doing all this in the view controller, and the corresponding lines are tracked through an enumeration:
enum { kNameRow, kGenderRow, kJobTypeRow, kLevelOfExerciseRow, kEmailAddressRow, kTelephoneNumberRow };
As I described, these cells are all very different, so the cells are displayed as follows:
// - tableView:cellForRowAtIndexPath pseudocode. switch (indexPath.row) { case kNameRow: // create name cell. case kGenderRow: // create gender cell. case kJobTypeRow: // create job type cell. case kLevelOfExerciseRow: // create level of exercise cell. case kEmailAddressRow: // create email address cell. case kTelephoneNumberRow: // create telephone number cell. }
And the interaction with the cells is handled similarly:
// - tableView:didSelectRowAtIndexPath pseudocode. switch (indexPath.row) { case kNameRow: // do name-specific stuff. case kGenderRow: // do gender-specific stuff. case kJobTypeRow: // do job type-specific stuff. case kLevelOfExerciseRow: // do level of exercise-specific stuff. case kEmailAddressRow: // do email address-specific stuff. case kTelephoneNumberRow: // do telephone number-specific stuff. }
This seems very cumbersome, and the problem of inoperability is added when the table is divided into several sections.
Is there a better way to do this? Are there any design patterns that I would use when working with large tables of largely unrelated data?
Any advice is generally greatly appreciated.