2

我为我的应用程序创建了一个 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?

4

1 回答 1

11

您无需将 QuickLook 插件复制到~/Library/QuickLook. 如果它在,YourApp.app/Contents/Library/QuickLook/那么系统将使用它 - 这适用于沙箱,因为除了将插件与您的应用程序捆绑在一起之外,您不需要做任何事情。

于 2012-12-19T08:48:33.370 回答