Skip to main content

Write pasteboard items (pasteboard.write_items)

Declaration

pasteboard.write_items(item [, options ])
pasteboard.write_items(items [, options ])

Parameters

  • item
    Table. A pasteboard item whose keys are UTIs and values are string data.

  • items
    Table. A list of pasteboard items.

  • options
    Table, optional. local_only: Boolean. Keep the content local to this device. Supported on iOS 10 and later. expiration_date: Number. Unix timestamp in seconds. Supported on iOS 10 and later.

    Pasteboard item structure
    {
    ["public.utf8-plain-text"] = "plain text",
    ["public.rtf"] = "RTF data",
    ["public.html"] = "HTML data",
    ["public.png"] = "PNG binary data",
    ...
    }

Returns

  • success
    Boolean. Returns true when writing succeeds; otherwise returns false.

Description

Write pasteboard items to the system pasteboard. A single item can provide multiple format representations. iOS 9 ignores options. This function is available in versions after 20260428.

Example

pasteboard.write_items({
{
["public.utf8-plain-text"] = "normal bold italic red\nHello",
["public.rtf"] = [[{\rtf1\ansi\deff0
{\fonttbl{\f0 Helvetica;}}
{\colortbl;\red255\green0\blue0;}
\f0\fs32 normal {\b bold} {\i italic} \cf1 red\cf0\par
Hello
}]],
["public.html"] = [[<p>normal <b>bold</b> <i>italic</i> <span style="color:red">red</span><br>Hello</p>]],
},
}, {
local_only = true,
expiration_date = os.time() + 3600,
})