// Copy to Clipboard
declare sub setValue lib “UIKit” selector “setValue:forPasteboardType:” (obj_id as ptr, value as ptr, pasteboardType as CFStringRef)
Dim MyClip as Text
MyClip = CurrentEntry.PostalCode + " " + CurrentEntry.PlaceName
// Copy ZIP and City to Clipboard
declare function generalPasteboard lib “UIKIt” selector “generalPasteboard” (clsRef as ptr) as ptr
declare function NSClassFromString lib “Foundation” (clsName as cfstringref) as ptr
declare function stringWithString lib “Foundation” selector “stringWithString:” (clsRef as ptr, str as cfstringref) as ptr
setValue(generalPasteboard(NSClassFromString(“UIPasteboard”)), stringWithString(NSClassFromString(“NSString”),MyClip), “public.text”)
This works no longer in iOS 11.x on a real device (iPhone, iPad). It works in the simulator with iOS 10.3.x and not on a device with iOS 11.
Yes, just to second this post. These declares no long appear to work for copying to the iOS pasteboard. Strangely, it does work when sharing the clipboard with the Mac in the simulator but does not work for copying text within the iOS in the simulator or on the device.
It would be really useful to have this functionality back again. Better still would simply be to have Clipboard ported to the iOS side of Xojo.
By the way, the code shown in the OP’s message is essentially identical to that shown in the “Pasteboard.xojo_binary_project” in the Example Projects>iOS>Declares folder that comes with the most recent version of Xojo.
This example does not work, probably for the same reason that Greg identified (though it is not clear to me why the generalPasteboard shouldn’t work as most of that documentation seems to imply that it still does work.