Sometimes I need to make a UITableView that resembles a menu and has rows that are known before compiling. I typically do this:
typedef enum {
PEPSI_SODA,
COKE_SODA,
DRPEPPER_SODA,
DIET_SODA,
COUNT_SODA
} SODAS;
I then return COUNT_SODA for the numberOfRowsInSection and a switch (indexPath.row) { case PEPSI_SODA: cell.textLabel.text = @"Pepsi" break; } for the cellForRowAtIndexPath method. Is this a “proper” use of typedef enum or is there a better way to approach these types of situations?
Create some type of UITableViewController subclass that you can pass a dictionary on the constructor. That way you can always reuse the same class in your projects. Your method is not reusable and produces a lot of effort to extend since you have to change things in various places to add a row.