我处理了从浏览器视图到自定义视图的拖动操作。它在雪豹中运行良好,但在带有沙箱的山狮中运行良好。
in browser view:
NSMutableArray* urls = [[[NSMutableArray alloc] init] autorelease];
..............put some NSUrl to urls array....................
[pasteboard writeObjects:[NSArray arrayWithArray:urls]];
in my receive custom view:
NSArray* pasteboardItems = [pasteboard readObjectsForClasses:[NSArray arrayWithObject:[NSString class]] options:nil];
NSArray* pasteboardItems2 = [pasteboard readObjectsForClasses:[NSArray arrayWithObject:[NSURL class]] options:nil];
NSArray* pasteboardItems3 = [pasteboard readObjectsForClasses:[NSArray arrayWithObject:[NSImage class]] options:nil];
NSLog(@"%@",pasteboardItems);
NSLog(@"%@",pasteboardItems2);
NSLog(@"%@",pasteboardItems3);
my log is:
2012-08-09 18:33:43.886 iCollage[6885:303] __CFPasteboardIssueSandboxExtensionForPath: error for [/Users/xxxx/Library/Containers/xxxxxxxxxxxx/Data/Downloads/1343902069.jpg]
2012-08-09 18:33:44.546 iCollage[6885:303] ( "file://localhost/Users/xxx/Library/Containers/xxxxxxxx/Data/Downloads/1343902069.jpg")
2012-08-09 18:33:44.547 iCollage[6885:303] ( "file://localhost/Users/xxxxx/Library/Containers/xxxxxx/Data/Downloads/1343902069.jpg")
2012-08-09 18:33:44.547 iCollage[6885:303] ()
我的问题是:
1.如何解决此错误__CFPasteboardIssueSandboxExtensionForPath;我参考了文档,但没有发现任何相关信息。我确保我有权访问该文件!谷歌说,可能是“startAccessingSecurityScopedResource”会帮助我,然后我尝试并失败了
2.为什么 pasteboardItems2 有价值?我只写到粘贴板的 url 而不是字符串。这让我感到恶心,我可以从 NSString 类型和 NSUrl 类型中获取 url!(我尝试从 iFinder 拖动一个文件,该 url 将只存在于 pasteboardItems 而不是 pasteboardItems2)。有人知道为什么吗?我认为当有人帮我解决这个问题时,第一个问题会自动解决。