I have this snippet of code:
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pboard declareTypes:[NSArray arrayWithObject:NSURLPboardType] owner:nil];
[pboard writeObjects:[NSArray arrayWithObject:[NSURL fileURLWithPath:@"/Users/dw/Desktop/macapp/Menulet/logo.png"]]];
And I don’t want to use an absolute path but when I try using just “logo.png” it gives the following error:
NSURLs written to the pasteboard via NSPasteboardWriting must be absolute URLs. NSURL 'logo.png -- file://localhost/Users/dw/Library/Developer/Xcode/DerivedData/Menulet-bvwpfkjlcufhxubvaxubgnubtfgi/Build/Products/Debug/' is not an absolute URL.
Is there anyway to not have to hardcode it? logo.png is currently in my Resources folder in Xcode.
EDIT:
How can I get a directory path instead?
This should make the trick:
Documentation here.