我为我的应用程序创建了一个 QuickLook 生成器,并Containers/com.Aravindh.EgApp/Data/Library/QuickLook/QuickLookGenerator.qlgenerator
使用以下代码将 quicklook 生成器复制到了这个位置。
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 中提及任何内容?如何在沙盒环境中安装 QuickLookGenerator?