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

# prepare(for:sender:)

Called when a segue is about to be performed.

```
@MainActor optional func prepare(for segue: NSStoryboardSegue, sender: Any?)
```

## Parameters

`segue`

The segue object containing information about the view controllers involved in the segue.

`sender`

The object that initiated the segue. You might use this parameter to perform different actions based on which control (or other object) initiated the segue.

## Discussion

The default implementation of this method does nothing; you can override it to pass relevant data to the new view controller or window controller, based on the context of the segue. The `segue` object describes the transition and includes references to both controllers involved in the segue.

Segues can be triggered from multiple sources, so use the information in the `segue` and `sender` parameters to disambiguate between different logical paths in your app. For example, if the segue originated from a table view, the `sender` parameter would identify the cell that the user clicked. You could use that information to set the data on the destination view controller.

---

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)