复制:
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
[pasteboard clearContents]; //必须清空,否则setString会失败。
[pasteboard setString:@"something" forType:NSStringPboardType];
粘贴:
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
NSArray *types = [pasteboard types];
if ([types containsObject:NSPasteboardTypeString]) {
NSString *s = [pasteboard stringForType:NSPasteboardTypeString];
//do something..
}
网友评论