Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As stated in the documentation:</p> <blockquote> <p>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.</p> <p>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.</p> </blockquote> <p>That being said, when you trigger the <code>segue</code>, normally it's because it's assumed that the <code>UIViewController</code> will be able to respond to it with a specific <code>segue's</code> 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:</p> <pre><code>if ([self canPerformSegueWithIdentifier:@"SegueID"]) [self performSegueWithIdentifier:@"SegueID"]; </code></pre> <p>I am guessing that:</p> <ol> <li><code>respondsToSelector:</code> only checks if you are able to handle that message in runtime. In this case you can, because the class <code>UIViewController</code> is able to respond to <code>performSegueWithIdentifier:sender:</code>. 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 <code>NSInvalidArgumentException</code> will rise.</li> <li>To actually create what you suggested, it would be helpful to receive a list of segue's id that the <code>UIViewController</code> is associated with. From the <code>UIViewController</code> <a href="http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIViewController_Class/Reference/Reference.html" rel="noreferrer">documentation</a>, I wasn't able to find anything that looks like that</li> </ol> <p>As for now, I am guessing your best bet it's to keep going with the <code>@try</code> <code>@catch</code> <code>@finally</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload