mirror of
https://github.com/skidoodle/ctx.git
synced 2026-04-28 19:27:41 +02:00
Use NSURL and writeObjects for pasteboard files
Create an NSURL from the path and write it to the general pasteboard with writeObjects:. Add nil checks for the created NSURL and remove the legacy NSFilenamesPboardType setPropertyList code.
This commit is contained in:
+5
-2
@@ -13,10 +13,13 @@ int copyFileToPasteboard(char* path) {
|
||||
NSString *strPath = [NSString stringWithUTF8String:path];
|
||||
if (!strPath) return 0;
|
||||
|
||||
NSURL *url = [NSURL fileURLWithPath:strPath];
|
||||
if (!url) return 0;
|
||||
|
||||
NSPasteboard *pb = [NSPasteboard generalPasteboard];
|
||||
[pb clearContents];
|
||||
[pb declareTypes:@[NSFilenamesPboardType] owner:nil];
|
||||
return [pb setPropertyList:@[strPath] forType:NSFilenamesPboardType] ? 1 : 0;
|
||||
|
||||
return [pb writeObjects:@[url]] ? 1 : 0;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user