Copy a string to the pasteboard
1). Write data to the pasteboard programmatically
UIPasteboard.general.setValue("hello", forPasteboardType: "public.plain-text")
2). Open another app for example, Google Chrome browser, and touch the address bar twice to show the edit menu (copy, cut, and paste commands). Then, touch Paste.Concepts
Pasteboard
UTI (Uniform Type Identifier)
UTI is a string to identify a class of entities (documents, pasteboard data, and bundles). UTI replaces the incompatible existing methods of tagging data. Currently, for example, a JPEG file is identified by any of the following methods:
1. A four character type code of JPEG
2. A filename extension of .jpg
3. A filename extension of .jpeg
4. A MIME type of image/jpeg
With UTI, the data is identified by the string public.jpeg. Then, we can use a utility function to translate from one to the other.
The key advantage of UTI over the other tagging methods is a conformance hierarchy. For example, the UTI public.html, which defines HTML text, conforms to the base text identifier, public.text. In this case, conformance lets applications which can open the general text files identify HTML files as ones i can open as well.
References
https://developer.apple.com/library/archive/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/UsingCopy,Cut,andPasteOperations/UsingCopy,Cut,andPasteOperations.html#//apple_ref/doc/uid/TP40009542-CH11-SW21
https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html#//apple_ref/doc/uid/TP40001319-CH202-CHDHIJDE
No comments:
Post a Comment