0

I have a beginner's question regarding the ReactiveCocoa. I want to return the value of shouldPerformSegueWithIdentifier method based on user interaction with UIAlertView. That's what I have so far, obviously it doesn't work. How should I proceed?

-(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender{
    if([identifier isEqualToString:ModalBrowser]){
        if(self.delegate.currentCoreConversation!=nil){
            UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Disconnect?" message:@"This action will disconnect you from your current conversation. Would you like to continue?" delegate:self cancelButtonTitle:@"Heck No Techno!" otherButtonTitles:@"Certainly", nil];
            [alertView show];
            [alertView.rac_buttonClickedSignal subscribeNext:^(NSNumber *x) {
                //    return [x isEqual:@1];
            }];
            [alertView.rac_buttonClickedSignal subscribeNext:^(NSNumber *x) {
                //    return [x isEqual:@1];
            }];
        }
    }
    return YES;
}
Sebastian
  • 7,670
  • 5
  • 38
  • 50
Janusz Chudzynski
  • 2,700
  • 3
  • 33
  • 46

1 Answers1

2

Alert views don't block the thread of execution when displayed. In other words, the user's tap will arrive after you've already returned from -shouldPerformSegueWithIdentifier:sender:.

Instead of trying to figure out a way to change that behavior, you should return NO immediately, and then programmatically trigger a segue later (after the user has responded to your alert view).

Justin Spahr-Summers
  • 16,893
  • 2
  • 61
  • 79