Created
April 8, 2014 15:44
-
-
Save Wevah/10145527 to your computer and use it in GitHub Desktop.
Using kPasteboardTypeFileURLPromise/kPasteboardTypeFilePromiseContent
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
- (NSArray *)writableTypesForPasteboard:(NSPasteboard *)pasteboard { | |
// pasteboard must be stored away because there's no way to get it in -pasteboardPropertyListForType: :( | |
_currentPasteboard = pasteboard; | |
NSArray *types = @[(id)kPasteboardTypeFileURLPromise, (id)kPasteboardTypeFilePromiseContent]; | |
return types; | |
} | |
// ... | |
- (id)pasteboardPropertyListForType:(NSString *)type { | |
if ([type isEqualToString:(NSString *)kPasteboardTypeFilePromiseContent]) | |
return someUTI; | |
else if ([type isEqualToString:(NSString *)kPasteboardTypeFileURLPromise]) { | |
NSURL *directoryURL = [NSURL URLWithString:[_currentPasteboard stringForType:@"com.apple.pastelocation"]]; | |
NSURL *finalURL = [NSURL URLWithString:[_filename stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] relativeToURL:directoryURL]; | |
// Write your file to finalURL here | |
return [finalURL absoluteString]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can't get a hold of
com.apple.pastelocation
— anything I could be doing wrong?