Deciding if an invoked segue should be performed
suggest changeshouldPerformSegueWithIdentifier:sender:
The Objective-C selector is shouldPerformSegueWithIdentifier:sender:. This Swift 3 override is the one to implement:
func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool
Determines whether the segue with the specified identifier should be performed.
Parameters
Identifier: the string that identifies the triggered segue
Sender: the object that initialized the segue
Example in Swift
Perform the segue only when the identifier is SomeSpecificIdentifier. Every other identifier returns false, which cancels that segue.
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
return identifier == "SomeSpecificIdentifier"
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents