我为我的应用程序创建了一个QuickLook Generator,并使用以下代码将quicklook生成器复制到此位置Containers/com.Aravindh.EgApp/Data/Library/QuickLook/QuickLookGenerator.qlgenerator
。
NSString *path1 = [[NSBundle mainBundle] pathForResource:@"QuickLookGenerator" ofType:@"qlgenerator"];
NSError *error;
NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask];
NSString *librayPath = [[paths objectAtIndex:0] path];
librayPath = [NSString stringWithFormat:@"%@/Quicklook/QuickLookGenerator.qlgenerator",librayPath];
if(![[NSFileManager defaultManager] fileExistsAtPath:librayPath]) {
[[NSFileManager defaultManager] copyItemAtPath:path1 toPath:librayPath error:&error];
}
但是我收到了这个错误:
Error Domain=NSCocoaErrorDomain Code=513 "“QuickLookGenerator.qlgenerator” couldn’t be copied because you don’t have permission to access “QuickLook”." UserInfo=0x101518250 {NSSourceFilePathErrorKey=/Users/Aravindh/Desktop/EgApp/EgApp/build/Release/EgApp.app/Contents/Resources/QuickLookGenerator.qlgenerator, NSUserStringVariant=(
Copy
), NSDestinationFilePath=/Users/Aravindh/Library/Containers/com.Aravindh.EgApp/Data/Library/Quicklook/QuickLookGenerator.qlgenerator, NSFilePath=/Users/Aravindh/Desktop/EgApp/EgApp/build/Release/EgApp.app/Contents/Resources/QuickLookGenerator.qlgenerator, NSUnderlyingError=0x10154dbb0 "The operation couldn’t be completed. Operation not permitted"}
我是否必须在Entitlementes.plist中提及任何内容?如何在SandBox环境中安装QuickLookGenerator?
答案 0 :(得分:11)
您无需将QuickLook插件复制到~/Library/QuickLook
。 If it's in YourApp.app/Contents/Library/QuickLook/
然后系统会使用它 - 这适用于沙盒,因为除了将插件与您的应用捆绑在一起之外,您不需要做任何事情。