UXPasteboardEntry
UXPasteboardEntry is one type/payload pair held by a
UXPasteboard.
#use <UXKit> // or #import "UXPasteboard.xc"Overview
Section titled “Overview”class UXPasteboardEntry : Object { u8* type; // "public.utf8-plain-text", "public.file-url", your own UTI u8* data; // the payload written for that type}One entry per type is the whole idea
Section titled “One entry per type is the whole idea”A pasteboard holds one payload per type, so a single copy can offer the same thing several ways and a paste takes the richest form it understands.
copy a shape: "com.example.shape" the real thing, exactly "public.utf8-plain-text" "Rectangle 100x60"Paste into your own canvas and you get the shape back. Paste into a text editor and you get a sensible line of text. Neither side negotiates: the writer offers what it can and the reader asks for what it wants.
Writing the same type twice replaces the payload. There are never two payloads for one type, so “ask for this type” has one answer.
Type strings are conventions, not an enum
Section titled “Type strings are conventions, not an enum”The types are plain strings. The toolkit defines the common ones by convention
(public.utf8-plain-text, public.file-url), and an application adds its own
by picking a string nobody else will use, usually in reverse-DNS form.
Nothing registers a type and nothing validates one. Two programs interoperate by agreeing on a string, as the platform pasteboards do.
public.file-url payloads are UXURL text, which
links file: URLs and UXPath.
Payloads are strings for now
Section titled “Payloads are strings for now”u8* dataText, serialised structures and URLs all travel as strings. Raw bytes are not supported yet.
Strings cover the current cases: a clipboard of text, a drag of file references, an application’s own model serialised as JSON. They also keep the pasteboard neutral across backends that disagree about binary formats. If your payload is binary, encode it.
Fields
Section titled “Fields”u8* typeThe type identifier, compared by content.
u8* dataThe payload.
Conforms to
Section titled “Conforms to”- Inherits
Object
See also
Section titled “See also”UXPasteboard: the board, and its change countUXURL: what apublic.file-urlpayload holdsUXJSON: a reasonable way to serialise your own type