---
title: "preferredPasteboardType(from:restrictedToTypesFrom:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextview/preferredpasteboardtype(from:restrictedtotypesfrom:)"
---

# preferredPasteboardType(from:restrictedToTypesFrom:)

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

## Declaration

```swift
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

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

## Discussion

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

### Related Documentation

- [pasteAsRichText(_:)](appkit/nstextview/pasteasrichtext(_:).md)
- [pasteAsPlainText(_:)](appkit/nstextview/pasteasplaintext(_:).md)

### Managing the pasteboard

- [readSelection(from:)](appkit/nstextview/readselection(from:).md)
- [readSelection(from:type:)](appkit/nstextview/readselection(from:type:).md)
- [readablePasteboardTypes](appkit/nstextview/readablepasteboardtypes.md)
- [writablePasteboardTypes](appkit/nstextview/writablepasteboardtypes.md)
- [writeSelection(to:type:)](appkit/nstextview/writeselection(to:type:).md)
- [writeSelection(to:types:)](appkit/nstextview/writeselection(to:types:).md)
- [validRequestor(forSendType:returnType:)](appkit/nstextview/validrequestor(forsendtype:returntype:).md)
