Reputation: 2710
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;
}
Upvotes: 0
Views: 592
Reputation: 16973
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).
Upvotes: 2