Reputation: 585
I am Using Drag and Drop to drop a File onto my APP.
Apple deprecated NSFilenamesPboardType in OSX 10.14 and suggests using NSPasteboardTypeFileURL.
The URL(String) I get is:
file:///.file/id=6571367.2682325
How do I get the Actual File Path from this URL ? I need File Name and Type info. Can I also access the File with the Full File Path ? I assume it is added to my Sandbox.
Upvotes: 2
Views: 876
Reputation: 11
I'm working at Mac OS 10.14 with Xcode 10.2.
I got two solutions in performDragOperation (both registerForDraggedTypes with NSPasteboardTypeFileURL. Then):
mentioned above
[[NSURL URLWithString:relativePath] fileSystemRepresentation];
init pasteBoard
NSString *fileURL = [[NSURL URLFromPasteboard:pasteBoard] path];
Upvotes: 1
Reputation: 585
I found the solution using:
NSURL * url = [NSURL initWithString:urlString];
NSString * path = [url fileSystemRepresentation];
And yes the file was accessible from my Sandboxed application.
Upvotes: 0