<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSAlert/delegate",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAlert(py)delegate"
  },
  "title" : "delegate"
}
-->

# delegate

The alert’s delegate.

```
weak var delegate: (any NSAlertDelegate)? { get set }
```

## Discussion

To set a delegate for the alert, provide an object conforming to the [`NSAlertDelegate`](/documentation/AppKit/NSAlertDelegate)protocol to this property. To remove the delegate, set this property’s value to `nil`.

---

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)