Created
February 2, 2016 19:11
-
-
Save JohnCoates/47218d0f82f97219685c to your computer and use it in GitHub Desktop.
Mac OS X Pasteboard Viewer : NSPasteboard extract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <AppKit/AppKit.h> | |
int main(int argc, char *argv[]) { | |
@autoreleasepool { | |
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; | |
NSLog(@"items: %@", pasteboard.pasteboardItems); | |
for (NSPasteboardItem *item in pasteboard.pasteboardItems) { | |
NSLog(@"types: %@", item.types); | |
for (NSString *type in item.types) { | |
NSData *data = [item dataForType:type]; | |
NSString *string = [item stringForType:type]; | |
NSLog(@"%@: %@", type, string); | |
NSLog(@"%@: %@", type, data); | |
NSString *writeOutPath = [NSString stringWithFormat:@"~/Temp/%@", type]; | |
writeOutPath = [writeOutPath stringByExpandingTildeInPath]; | |
[data writeToFile:writeOutPath atomically:YES]; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I recommend running this with CodeRunner 😃 https://coderunnerapp.com/