いくつかのオプションがあります:
プロトコルの名前を別の名前に変更します。
外部プロトコルを作成し、各ビューでそのプロトコルを採用します
親のタイプを使用して、ParentControllerというプロパティをビューに追加します。
@property(strong、nonatomic)ParentViewController * ParentController;
(コース外の合成)
次に、viewControllerで、ビューをインスタンス化するときに、viewControllerを親として割り当てます
YourView *childView = [[YourView alloc]init];
childView.parentController = self;
これで、文字列配列を受け取ることができるメソッドをviewControllerに追加できます。
-(void)setStringsArray:(NSArray*)arr{
//do what ever you need with the array
//don't forget to add this method to your .h file so it will be visible
}
最後に、ビューから文字列配列を送信します。[self.parentController setStringsArray:yourArray];
ところで
、どのビューが配列を送信するかを知りたい場合は、次のことができます。
-(void)setStringsArray:(NSArray*)arr fromView:(UIView*)senderView{
//do what ever you need with the array
//don't forget to add this method to your .h file so it will be visible
}
と使用
[self.parentController setStringsArray:yourArray fromView:self];
ところで2
他のオプションは通知を使用することです。