Question

I have a button with a action (toggleApplication) that opens another application. When I return to my application from the one that was opened I want to segue to another view. But I get the following error from my code:

Receiver (RootViewController: 0x1f192450) has no segue with identifier 'showReceipt'

AppDelegate.m

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

        RootViewController *controller = [RootViewController alloc];

        return [controller handleURL:url];

    }

RootViewController.m

- (IBAction)toggleApplication:(id)sender{

     // Open application
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:theUrlString]];

}

- (BOOL)handleURL:(NSURL *)url{

     [self performSegueWithIdentifier:@"showReceipt" sender:self];

     return YES;

}
Was it helpful?

Solution

Figured it out by using NSNotificationCenter.

AppDelegate.m

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

        [[NSNotificationCenter defaultCenter] postNotificationName:@"segueListener" object:nil];

        return YES;

    }

RootViewController.m

- (void)viewDidLoad{

     [super viewDidLoad];

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiptSegue) name:@"segueListener" object:nil];

}    

- (IBAction)toggleApplication:(id)sender{

     // Open application
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:theUrlString]];

    }

   - (void)receiptSegue{
        [self performSegueWithIdentifier:@"showReceipt" sender:self];
   }

Does exactly what I want. Don't know if it's the right approach though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top