Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8177161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:26:29+00:00 2026-06-06T23:26:29+00:00

This might be a very simple question but didn’t yield any results when searching

  • 0

This might be a very simple question but didn’t yield any results when searching for it so here it is…

I am trying to work out a way to check if a certain view controller can perform a segue with identifier XYZ before calling the performSegueWithIdentifier: method.

Something along the lines of:

if ([self canPerformSegueWithIdentifier:@"SegueID"])
    [self performSegueWithIdentifier:@"SegueID"];

Possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:26:32+00:00Added an answer on June 6, 2026 at 11:26 pm

    As stated in the documentation:

    Apps normally do not need to trigger segues directly.
    Instead, you configure an object in Interface Builder associated with
    the view controller, such as a control embedded in its view hierarchy,
    to trigger the segue. However, you can call this method to trigger a
    segue programmatically, perhaps in response to some action that cannot
    be specified in the storyboard resource file. For example, you might
    call it from a custom action handler used to process shake or
    accelerometer events.

    The view controller that receives this message must have been loaded
    from a storyboard. If the view controller does not have an associated
    storyboard, perhaps because you allocated and initialized it yourself,
    this method throws an exception.

    That being said, when you trigger the segue, normally it’s because it’s assumed that the UIViewController will be able to respond to it with a specific segue's identifier. I also agree with Dan F, you should try to avoid situations where an exception could be thrown. As the reason for you not to be able to do something like this:

    if ([self canPerformSegueWithIdentifier:@"SegueID"])
        [self performSegueWithIdentifier:@"SegueID"];
    

    I am guessing that:

    1. respondsToSelector: only checks if you are able to handle that message in runtime. In this case you can, because the class UIViewController is able to respond to performSegueWithIdentifier:sender:. To actually check if a method is able to handle a message with certain parameters, I guess it would be impossible, because in order to determine if it’s possible it has to actually run it and when doing that the NSInvalidArgumentException will rise.
    2. To actually create what you suggested, it would be helpful to receive a list of segue’s id that the UIViewController is associated with. From the UIViewController documentation, I wasn’t able to find anything that looks like that

    As for now, I am guessing your best bet it’s to keep going with the @try @catch @finally.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a very simple question for you, but I'm stumped. I'm trying
this might be a very simple question but I need your help. I work
This might be a very simple question but after much searching on different forums
This might be a very newbie question, but I didn't find anything satisfying I
This question might appear very simple, but i haven't found an answer yet, so
This might be a very simple question but i am unable to get it.
This might be a very simple question, but more or less, I'm asking to
This might come across as a simple question, but I have very limited experience
This might seem like a very simple question, but I am struggling with it.
This might be a very simple question, but I can't get it working. All

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.