単一の UIViewController サブクラスで、必要なものすべてを提供できると思います。それぞれの異なるタイプの画像をサポートするために必要な違いを提供するだけです。これらの違いは、表示される画像の説明とタイプにすぎないと仮定しましょう。
MyViewController.h:
@MyViewController : UIViewController
@property (strong, nonatomic) NSString *description;
@property (strong, nomatomic) NSString *type;
// Designated initializer
- (id)initWithNibName:(NSString *)nibName
bundle:(NSBundle *)nibBundle
description:(NSString *)description
type:(NSString *)type;
@end
MyViewController.m:
@implementation MyViewController
- (id)initWithNibName:(NSString *)nibName
bundle:(NSBundle *)nibBundle
description:(NSString *)description
type:(NSString *)type
{
self = [super initWithNibName:nibName bundle:nibBundle];
if (self != nil)
{
self.description = description;
self.type = type;
}
return self;
}
- (NSArray *)fetchPics
{
NSMutableArray *pics = [[NSMutableArray alloc] init];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.somewhere.com/fetchPics?type=%@", self.type]];
...
return pics;
}
@end
そして、必要に応じてView Controllerを作成するだけのケースになるはずです:
MyViewController *catVC = [[MyViewController alloc] initWithNibNamed:@"Something" bundle:nil description:@"Cats" type:@"cat"];
...