ペーストボードにテキストを貼り付けた私の実験は次のとおりです。ボタンを使用して、プログラムでテキストを追加しています。
#import <MobileCoreServices/MobileCoreServices.h>
- (IBAction)setPasteboardText:(id)sender
{
UIPasteboard *pb = [UIPasteboard generalPasteboard];
NSString *text = @"東京京都大阪";
// Works, but generates an incompatible pointer warning
[pb setValue:text forPasteboardType:kUTTypeText];
// Puts generic item (not text type), can't be pasted into a text field
[pb setValue:text forPasteboardType:(NSString *)kUTTypeItem];
// Works, even with non-ASCII text
// I would say this is the best way to do it with unknown text
[pb setValue:text forPasteboardType:(NSString *)kUTTypeText];
// Works without warning
// This would be my preferred method with UTF-8 text
[pb setValue:text forPasteboardType:(NSString *)kUTTypeUTF8PlainText];
// Works without warning, even with Japanese characters
[pb setValue:text forPasteboardType:@"public.plain-text"];
// Works without warning, even with Japanese characters
[pb setValue:text forPasteboardType:@"public.text"];
// Check contents and content type of pasteboard
NSLog(@"%@", [pb items]);
}
内容をテキストフィールドに貼り付けて確認し、テキストの内容を毎回変更して、以前の貼り付けを再利用していないことを確認しました。