10

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

Jonathan Leffler
  • 698,132
  • 130
  • 858
  • 1,229
Man of One Way
  • 3,874
  • 1
  • 24
  • 40

1 Answers1

15

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...
mmmmmm
  • 31,464
  • 27
  • 87
  • 113