In my sandboxed app, I'm trying to put NSURLs with security scope onto the pasteboard for a drag'n'drop from an NSTableView to the finder (and vice-versa).
The code for the drag is fairly simple, basically doing a writeObjects on the pasteboard with an array of NSURLs:
- (BOOL) tableView:(NSTableView *)tv
writeRowsWithIndexes:(NSIndexSet *)rowIndexes
toPasteboard:(NSPasteboard *)pasteboard
{
Crate *selectedCrate = (Crate *)[self.cratesListController selectedObjects][0];
NSMutableArray *pasteboardArray = [NSMutableArray array];
[rowIndexes enumerateIndexesUsingBlock:^(NSUInteger rowIndex, BOOL *stop) {
Track *selectedTrack = [self.tracksViewedInTrackList objectAtIndex:rowIndex];
[selectedTrack addURLToPasteboardArray:pasteboardArray];
}];
if (!pasteboardArray.count) {
return NO;
}
for (NSURL *url in pasteboardArray) {
[url startAccessingSecurityScopedResource];
}
[pasteboard writeObjects:pasteboardArray];
for (NSURL *url in pasteboardArray) {
[url stopAccessingSecurityScopedResource];
}
return YES;
}
this works just fine and I can actually drop files onto my desktop but I get the following error logged:
2013-11-19 10:29:30.897 Test[1287:532f] sandbox extension creation failed: permissions error for path: [/Users/didier/Music/Gigs/Air Miles (2000 And One & DJ Madskillz).aif]
2013-11-19 10:29:30.897 Test[1287:532f] __CFPasteboardCreateSandboxExtensionDataFromCFData : failed to obtain sandbox extension data for url [file:///Users/didier/Music/Gigs/Air%20Miles%20(2000%20And%20One%20&%20DJ%20Madskillz).aif?applesecurityscope=623934663665316437323138646462333764326637373538626564363731393563303065616233303b30303030303030303b30303030303030303b303030303030303030303030303032303b636f6d2e6170706c652e6170702d73616e64626f782e726561642d77726974653b30303030303030313b30313030303030343b303030303030303030303061336431343b2f75736572732f64616d69656e2f6d757369632f67696773]
When trying to retrieve the URLs from the pasteboard, for a drop within my own app, like this:
NSArray *urls = [pasteboard readObjectsForClasses:@[ [NSURL class] ]
options:@{
NSPasteboardURLReadingFileURLsOnlyKey : @YES }];
Again the code works but the following error is logged:
2013-11-19 10:37:57.220 Krates[1287:303] No valid sandbox extension for item: [789514] of flavor: [public.file-url] was created.
2013-11-19 10:37:57.220 Krates[1287:303] Failed to get a sandbox extensions for itemIdentifier (789514). The data for the sandbox extension was NULL
Do I ignore these or am I missing something in my code?