UIViewController をセットアップする方法が最適なのか、それとも単純にばかげているのか疑問に思っています。
いくつかのカテゴリで列挙型を型定義しました。6つの異なるカテゴリがあるとしましょう。したがって、どのカテゴリが選択されているかによって異なります。私の UIViewController には、選択したカテゴリに従って UIView をセットアップするために別のメソッドを呼び出すスイッチがあります。
これがこれを行うための良い方法なのか、それとも 6 つの異なる UIViewController を作成することを検討すべきなのか疑問に思っていますか?
賛否両論の議論は大歓迎です。
ありがとう。
それらは基本的に同じです。
サンプルコード:
switch (self.category) {
case vegetables:
recipe = [[[WebServices sharedInstance].recipeDictionary objectForKey:self.chosenCategory] objectAtIndex:4]; //Needs to be made random
descriptionText.text = recipe.recipeDescription;
[self setupText];
[self setupVegetablesView];
break;
case dairy:
recipe = [[[WebServices sharedInstance].recipeDictionary objectForKey:self.chosenCategory] objectAtIndex:4]; //Needs to be made random
descriptionText.text = recipe.recipeDescription;
[self setupText];
[self setupDairyProductsView];
break;
- (void)setupVegetablesView
{
descriptionText.textColor = [UIColor colorWithRed:0/255.0 green:103/255.0 blue:55/255.0 alpha:1];
background.image = imageBackgroundVegetables;
topBar.image = topBarForVegetables;
subtitle.image = subtitleImageVegetables;
subtitleLink.image = subtitleLinkBarVegetables;
...
}