关于Mac复制粘贴之NSPasteBoard

复制:

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..     
}

你可能感兴趣的:(关于Mac复制粘贴之NSPasteBoard)