Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To recap your problem: </p> <ul> <li>A is a parent of B. </li> <li>A and B call C. </li> <li>A and B listen to C. </li> <li>When C send notification both A and B respond but you only want one of them to respond.</li> </ul> <p>I suggest letting A handle all communication with C, so if B need to talk to C it needs to go through A. This is how you can do this:</p> <p>in UiViewController A</p> <pre><code>-(void) viewDidLoad{ //Adding a notification listener should be done in initialization stage. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismissViewC:) name:@"dismiss_popup" object:nil]; } - (void) comment{ if (&lt;user_logged_in&gt;){ //proceed with comment } else { NSNumber* caller=[NSNumber numberWithInt:COMMENT]; [Logistic login:caller]; } } -(void) dismissViewC:(NSNotification*) notify{ (NSNumber*) callerId =[notify object]; switch(callerId.intValue){ case COMMENT: //proceed with comment; case: SHARE: [self.viewB share]; } } -(void) dealloc { // removing an observer should be done in the dealloc stage [[NSNotificationCenter defaultCenter] removeObserver:self]; } </code></pre> <p>in UIView B:</p> <pre><code> - (void) share{ if (&lt;user_logged_in&gt;){ //proceed with share } else { NSNumber* caller=[NSNumber numberWithInt:SHARE]; [Logistic login:caller]; } } </code></pre> <p>Logistics will need to pass the new login parameter to C and C will look like this:</p> <pre><code>-(void) login:(NSNumber*) caller{ self.myCaller=caller; // proceed with login } -(void) dismissMe{ [[NSNotificationCenter defaultCenter] postNotificationName:@"dismiss_popup" object:self.caller]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload