cacao
cacao copied to clipboard
Implement `writeObjects` for Pasteboard
trafficstars
Referencing this Stack Overflow article, the following code allows the user to copy some object (in this case, a file) to the clipboard:
NSURL *object = [[NSURL alloc] initFileURLWithPath:@"/Users/username/Desktop/main.png"];
NSPasteboard *pb = [NSPasteboard generalPasteboard];
[pb clearContents];
NSArray *objectsToCopy = [[NSArray alloc] initWithObjects:object, nil];
BOOL pasted = [pb writeObjects:objectsToCopy];
if(pasted) // paste was successful
NSLog(@"pasted");
[object release];
[objectsToCopy release];
[pb release];
However, after reading through the documentation/the Pasteboard implementation, it does not appear that there is a straightforward way to do this by using Cacao, as there is only support for writing text to the Pasteboard (clipboard).
This should actually be easier in the 0.3 branch, which I need to land. Will revisit it then - hopefully within the next week or two.
Hey! Any update on this request?