Reputation: 11039
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
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
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