<!--
{
  "availability" : [
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSSeguePerforming/shouldPerformSegue(withIdentifier:sender:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSSeguePerforming(im)shouldPerformSegueWithIdentifier:sender:"
  },
  "title" : "shouldPerformSegue(withIdentifier:sender:)"
}
-->

# shouldPerformSegue(withIdentifier:sender:)

Called immediately prior to the performance of a storyboard segue.

```
@MainActor optional func shouldPerformSegue(withIdentifier identifier: NSStoryboardSegue.Identifier, sender: Any?) -> Bool
```

## Parameters

`identifier`

The string that identifies the segue to be performed.

    Using the Interface Builder inspector, provide a unique identifier string for each segue in a storyboard. The system provides a segue’s identifier to this parameter when it calls this method. The identifier string is used to locate the segue inside the storyboard file that contains the view controller.
  
  > Note:
  > This method throws an [Exception handling](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/ExceptionHandling.html#//apple_ref/doc/uid/TP40008195-CH18) if there is no segue with the specified identifier.

`sender`

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

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> to allow a segue to proceed or <doc://com.apple.documentation/documentation/Swift/false> to stop it from proceeding.

## Discussion

Override this method to return <doc://com.apple.documentation/documentation/Swift/false> for cases where you want to prevent the performance of a segue. By default, invocation of a segue results in the segue being performed.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)