2017-01-30 18 views
1

ViewController FにViewController Cとの通信を許可します。 これらは次のように配置されます。 Navigation Controller AはViewController Bを組み込みます。 ViewController BからNavigationController DへのSegueがあり、ViewController EとViewController F(EとFの間のセグ)が埋め込まれています。必要ViewControllers間で委任「パス」をビルドアップ:ViewControllerをEへのViewController Fの代表者、最終的には代表者情報のViewControllerにC.が
それは感じているのViewController Bに委任し、直接接続されていない2つのViewController間の通信

私の現在の作業ソリューションは以下のとおりです。これを行う簡単な方法が必要であるように。 お勧めできますか?多分ViewController CをViewController Fの "segue path"の中に入れて、CとFの間の直接の委任を設定しますか?

ありがとうございます!

+0

'communicate'は何を意味するのでしょうか?メソッドを実行しますか?データを前後に渡しますか?イベントに返信しますか?あなたの質問は不明です。シングルトン、委任、NSNotificationCenter'のような多くの可能なメソッドがあります。 –

+0

私の場合、通信手段を意味します:Fは、Cのメソッドをトリガーし、途中でデータを渡すことができる必要があります。不明な質問を申し訳ありません。それを指摘してくれてありがとう! – seb

答えて

2

私はViewControllerをFでNSNotification

を使用します。

- (void)sendData { 
    // Fire the notification 
    [[NSNotificationCenter defaultCenter] postNotificationName:@"ReceivedData" 
                 object:nil]; 
} 

をViewControllerをCで:

- (void)viewDidLoad { 
    [NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(receivedDataNotification:) 
               name:@"ReceivedData" 
               object:nil]; 
} 

- (void)receivedDataNotification:(id)object { 
    NSLog(@"Received Data!"); 
} 
+0

私に正しい方向を教えていただきありがとうございます!私は現在 '[NSNotificationCenter defaultCenter] postNotificationName:@" ReceivedData "オブジェクトを使用しています:self userInfo:userInfo];' – seb

関連する問題