<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextView/preferredPasteboardType(from:restrictedToTypesFrom:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextView(im)preferredPasteboardTypeFromArray:restrictedToTypesFromArray:"
  },
  "title" : "preferredPasteboardType(from:restrictedToTypesFrom:)"
}
-->

# preferredPasteboardType(from:restrictedToTypesFrom:)

Returns whatever type on the pasteboard would be most preferred for copying data.

```
func preferredPasteboardType(from availableTypes: [NSPasteboard.PasteboardType], restrictedToTypesFrom allowedTypes: [NSPasteboard.PasteboardType]?) -> NSPasteboard.PasteboardType?
```

## Parameters

`availableTypes`

The types currently available on the pasteboard.

`allowedTypes`

Types allowed in the return value. If `nil`, any available type is allowed.

## Return Value

The preferred type to provide given the available types and the allowed types.

## Discussion

You should not need to override this method. You should also not need to invoke it unless you are implementing a new type of pasteboard to handle services other than copy/paste or dragging.

## See Also

[`-  pasteAsRichText:`](/documentation/AppKit/NSTextView/pasteAsRichText(_:))

This action method inserts the contents of the pasteboard into the receiver’s text as rich text, maintaining its attributes.

[`-  pasteAsPlainText:`](/documentation/AppKit/NSTextView/pasteAsPlainText(_:))

Inserts the contents of the pasteboard into the receiver’s text as plain text.



---

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)