これが1つの選択肢の図です。これはobjcカテゴリを使用しています。
/* File: Header A */
@interface MONViewController : NSViewController
{
unsigned anIvar;
}
@property (nonatomic, readonly) unsigned anIvar;
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle;
- (void)dealloc;
- (void)viewDidLoad;
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
/* (continued) */
@end
/* File: Header A or Header B, depending on how you want to organize it */
@interface MONViewController (EventCallbacks)
- (IBAction)triviaButtonWasPressed:(id)sender;
/* (continued) */
@end
/* File: Imp A */
@implementation MONViewController
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle { /* ... */ }
- (void)dealloc { /* ... */ }
- (unsigned)anIvar { /* ... */ }
- (void)viewDidLoad { /* ... */ }
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { /* ... */ }
/* (continued) */
@end
/* File: Imp A or Imp B, depending on how you want to organize it */
@implementation MONViewController (EventCallbacks)
- (IBAction)triviaButtonWasPressed:(id)sender { /* ... */ }
/* (continued) */
@end
幸い、コンパイラは、クラスで実行されるように、カテゴリが定義されたときにすべての宣言が定義されていることを確認します。プロトコルなど、適切なクラス実装で定義する必要があるものもあります。
これを大量の小さなファイルに分割する場合は注意が必要です。ビルド時間が大幅に短縮される可能性があります。また、この場合(サブクラス化のため)はやや避けられませんが、この点でのスケーラビリティの問題は、インターフェイス/クラスがやりすぎを試みていることを思い出させるものとして機能し、より小さなコンポーネントに分割する必要があります。幸運を!