iOS Segues Preparing your view controller before a triggering a Segue



 func prepareForSegue(_ segue:UIStoryboardSegue, sender sender:AnyObject?) 

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


segue: The segue object.

sender: The object that initialized the segue.

Example in Swift

Perform a task if the identifier of the segue is "SomeSpecificIdentifier"

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "SomeSpecificIdentifier" {
        //- Do specific task