我在浏览器视图中处理了拖放操作,将其拖到自定义视图中。它在雪豹系统中运行良好,但在带有沙盒的Mountain Lion系统中却无法正常工作。
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)。有人知道原因吗?我认为第一个问题在有��帮我解决这个问题之后会自动解决。