<!--
{
  "availability" : [
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSViewController/present(_:asPopoverRelativeTo:of:preferredEdge:behavior:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSViewController(im)presentViewController:asPopoverRelativeToRect:ofView:preferredEdge:behavior:"
  },
  "title" : "present(_:asPopoverRelativeTo:of:preferredEdge:behavior:)"
}
-->

# present(_:asPopoverRelativeTo:of:preferredEdge:behavior:)

Presents another view controller as a popover.

```
func present(_ viewController: NSViewController, asPopoverRelativeTo positioningRect: NSRect, of positioningView: NSView, preferredEdge: NSRectEdge, behavior: NSPopover.Behavior)
```

## Parameters

`viewController`

The other view controller to present as a popover.

`positioningRect`

The content size of the popover.

`positioningView`

The view relative to which the popover should be positioned. Must not be `nil`, or else the view controller raises an <doc://com.apple.documentation/documentation/Foundation/NSExceptionName/invalidArgumentException> exception.

`preferredEdge`

The edge of `positioningView` that the popover should prefer to be anchored to.

`behavior`

The popover’s closing behavior. See the [`NSPopover.Behavior`](/documentation/AppKit/NSPopover/Behavior-swift.enum) enumeration.

## Discussion

This method calls the [`present(_:animator:)`](/documentation/AppKit/NSViewController/present(_:animator:)) method on `self` (the presenting view controller), and passes a popover animator to that method.

The presented view controller is the delegate and the content view controller of the popover. You can use [`NSPopoverDelegate`](/documentation/AppKit/NSPopoverDelegate) methods to customize the popover.

To dismiss the popover, call the [`dismiss(_:)`](/documentation/AppKit/NSViewController/dismiss(_:)-91my5) method on `self` (the presenting 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)