Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access clipboard data programmatically?

How is it possible to access clipboard data on the Mac programmatically?

like image 317
Man of One Way Avatar asked Jul 31 '11 10:07

Man of One Way


1 Answers

Apple has a Pasteboard Programming Guide the main class you are looking for is NSPasteboard

The example for reading strings is

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...
like image 147
mmmmmm Avatar answered Oct 15 '22 19:10

mmmmmm