I have a question regarding set up table view with hard coded data. Sometime developer face with situation when you need to display data that is received not form DATA MODEL layer, but stored as hard coded information.
What I mean For example when you build Settings screen, there can be some UITableViewCell like:
CustomTableViewCellName - Configuration data: placeholder name/surname, icon.
CustomTableViewCellPhone - Configuration data: phone placeholder, icon.
CustomTableViewCellLogout - Configuration data: logout/sign out text, icon.
Let's assume I have 3 table view section and each section contains 5 different cells that I described above as example of different cases.
if we will implement all these cells in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.section)
..... A LOT OF CASES THAT CONFIGURE EACH CUSTOM CELLS
As you see there is no DATA MODEL only placeholders and icon images that will be stored in UITableViewCell as a default data for the labels, textviews image views and etc. I don't say about model here as about model USER for example that stores user name, surname and etc. I mean that I need to store some default data somewhere, maybe in a dictionary. Actually a placeholder is just a placeholder, though it has a TEXT and TEXT is a data =)
In this case we have data for configure default state of views and data that will use for example as model USER.
What I worry about that I will have a big Switch and very Massive View Controller.
I would like to create few methods that will represent sections with a switch using indexPath.row in them:
- (UITableViewCell *)cellsForSection1:(NSIndexPath *)ip
- (UITableViewCell *)cellsForSection2:(NSIndexPath *)ip
- (UITableViewCell *)cellsForSection2:(NSIndexPath *)ip
and move these methods to Interactor that will return for me a cell. I know that Interactor should prepare only data and push it over Presenter to a View.
Maybe I overthink a problem. I just don't want to have a big switch in VC =) I understand that there is no right solution. But maybe someone faced with it.
One more time in my case the data are the default cells that I want to configure somewhere to prevent overload view controller. Yea maybe it looks crazy that cells are data, but look at ViewController that contains 1000 lines of code for configuration cellForRowAtIndexPath
is also crazy =)