Instance Method

shouldPerformSegue(withIdentifier:sender:)

Determines whether the segue with the specified identifier should be performed.

Declaration

func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool

Parameters

identifier

The string that identifies the triggered segue. In Interface Builder, you specify the segue’s identifier string in the attributes inspector. This string is used only for locating the segue inside the storyboard.

sender

The object that initiated the segue. This object is made available for informational purposes during the actual segue.

Return Value

true if the segue should be performed or false if it should be ignored.

Discussion

Subclasses can override this method and use it to perform segues conditionally based on current conditions. If you do not implement this method, all segues are performed.

See Also

Interacting with Storyboards and Segues

var storyboard: UIStoryboard?

The storyboard from which the view controller originated.

func prepare(for: UIStoryboardSegue, sender: Any?)

Notifies the view controller that a segue is about to be performed.

func performSegue(withIdentifier: String, sender: Any?)

Initiates the segue with the specified identifier from the current view controller'€™s storyboard file.

func allowedChildViewControllersForUnwinding(from: UIStoryboardUnwindSegueSource)

Returns an array of child view controllers that should be searched for an unwind segue destination.

func childViewControllerContaining(UIStoryboardUnwindSegueSource)

Returns the child view controller that contains the source of the unwind segue.

func canPerformUnwindSegueAction(Selector, from: UIViewController, withSender: Any)

Called on a view controller to determine whether it wants to respond to an unwind action.

func unwind(for: UIStoryboardSegue, towardsViewController: UIViewController)

Called when an unwind segue transitions to a new view controller.