I have learned that when you copy selected text from a UIWebView
into UIPasteboard
, it actually puts multiple keyed values into the dictionary returned by UIPasteboard, of which "com.apple.rtfd" is only the first key. The actual text value of the copied element is also included under the key "public.text". This code can be used to extract the value:
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSArray *dataArray = [pasteboard items];
NSDictionary *dict = (NSDictionary *)[dataArray objectAtIndex:0];
NSString *pastedText;
if ([dict objectForKey:@"public.text"]) {
// this is a text paste
pastedText = (NSString *)[dict objectForKey:@"public.text"];
}