I am trying to put both a string and an image onto the pasteboard. If I use
let str : String
let img : UIImage
// ...
UIPasteboard.general.items = [ [ String ( kUTTypeText ) : str ],
[ String ( kUTTypeImage ) : img ] ]
the image pastes fine but not the string. The string is in this weird encoded form.
I've tried different types as well as converting the string to NSString
or UTF8
but it either crashes with value for pasteboard type 'public.text' is not a valid property list type
or the string remains in some coded form.
EDIT
If I paste it into Notes this is what I see.
and if I tap on the text it expands into
while if I add
print ( "Copied ( str )" )
I get
Copied 960 939 379 918 958 884 971 672 962 127 852 754 715 ...
in the console.
Also, if I just do
UIPasteboard.general.string = str
it works as expected albeit then I only copy a string.
question from:
https://stackoverflow.com/questions/65856771/placing-both-string-and-image-on-pasteboard 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…