arturdev
arturdev

Reputation: 11039

iOS SDK- How to get segue identifiers of viewController?

Is there a way to get all segue identifiers for VC ?

Or just to know has the VC segue with identifier?

Thank you.

Upvotes: 4

Views: 5021

Answers (2)

Sam Fischer
Sam Fischer

Reputation: 1472

Sadly, there is no method or property that one can use to get all the identifiers of the various segues in a storyboard.

To get the identifier of a particular segue, you can use the following code in the prepareForSegue method in the implementation of your UIViewController :

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
  NSString *segueIdentifier = segue.identifier; //This object stores your segue's identifier
  NSLog(@"%@", segueIdentifier);
}

Upvotes: 1

Atif Alvi
Atif Alvi

Reputation: 498

No, there is no way to do what you are looking for.

If you could tell us why you need this then may be some one can give you directions to an alternative.

Edited:

If you really want to do it this way than you can use try/catch, something like this should work:

@try
{
    [self performSegueWithIdentifier:@"first" sender:self];

}
@catch (NSException *exception)
{
    if ([exception.name isEqualToString:@"NSInvalidArgumentException"])
    {
        NSLog(@"NSInvalidArgumentException");
        [self performSegueWithIdentifier:@"second" sender:self];
    }
}

Upvotes: 1

Related Questions