如何以编程方式访问Mac上的剪贴板数据?
答案 0 :(得分:16)
Apple有一个Pasteboard Programming Guide您要查找的主要课程是NSPasteboard
读取字符串的示例是
NSPasteboard *pasteboard = <#Get a pasteboard#>;
NSArray *classes = [[NSArray alloc] initWithObjects:[NSString class], nil];
NSDictionary *options = [NSDictionary dictionary];
NSArray *copiedItems = [pasteboard readObjectsForClasses:classes options:options];
if (copiedItems != nil) {
// Do something with the contents...