<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSPasteboard/declareTypes(_:owner:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPasteboard(im)declareTypes:owner:"
  },
  "title" : "declareTypes(_:owner:)"
}
-->

# declareTypes(_:owner:)

Prepares the receiver for a change in its contents by declaring the new types of data it will contain and a new owner.

```
func declareTypes(_ newTypes: [NSPasteboard.PasteboardType], owner newOwner: Any?) -> Int
```

## Parameters

`newTypes`

An array of `NSString` objects that specify the types of data that may be added to the new pasteboard. The types should be ordered according to the preference of the source application, with the most preferred type coming first (typically, the richest representation).

`newOwner`

The object responsible for writing data to the pasteboard, or `nil` if you provide data for all types immediately. If you specify a `newOwner` object, it must support all of the types declared in the `newTypes` parameter and must remain alive for as long as the data is *promised* on the pasteboard.

## Return Value

The receiver’s new change count.

## Discussion

This method is the equivalent of invoking [`clearContents()`](/documentation/AppKit/NSPasteboard/clearContents()), implicitly writing the first pasteboard item, and then calling [`addTypes(_:owner:)`](/documentation/AppKit/NSPasteboard/addTypes(_:owner:)) to promise types for the first pasteboard item.

> Note:
> In macOS 10.5 and earlier, this method is the first step in writing data to the pasteboard and must precede the messages that actually write the data. A ``doc://com.apple.appkit/documentation/AppKit/NSPasteboard/declareTypes(_:owner:)`` message essentially changes the contents of the receiver: It invalidates the current contents of the receiver and increments its change count.

### Special Considerations

In general, you should not use this method with [`writeObjects(_:)`](/documentation/AppKit/NSPasteboard/writeObjects(_:)), since [`writeObjects(_:)`](/documentation/AppKit/NSPasteboard/writeObjects(_:)) will always write additional items to the pasteboard, and will not affect items already on the pasteboard, including the item implicitly created by this method.

## See Also

[`clearContents()`](/documentation/AppKit/NSPasteboard/clearContents())

Clears the existing contents of the pasteboard.

[`changeCount`](/documentation/AppKit/NSPasteboard/changeCount)

The receiver’s change count.

  <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/pasteboard:provideDataForType:>



---

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)