10

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

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Man of One Way
  • 3,904
  • 1
  • 26
  • 41

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
  • 32,227
  • 27
  • 88
  • 117