相关疑难解决方法(0)

NSFileManager创建文件夹(Cocoa错误513.)

我正在尝试在我的应用程序的/ sounds文件夹中创建一个文件夹.

-(void)productPurchased:(UAProduct*) product {
    NSLog(@"[StoreFrontDelegate] Purchased: %@ -- %@", product.productIdentifier, product.title);

    NSFileManager *manager = [NSFileManager defaultManager];
    NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];

    NSError *error;

    NSString *dataPath = [NSString stringWithFormat:@"%@/sounds/%@", bundleRoot, product.title];

    if (![manager fileExistsAtPath:dataPath isDirectory:YES]) {
        [manager createDirectoryAtPath:dataPath withIntermediateDirectories:YES attributes:nil error:&error];
        NSLog(@"Creating folder");
    }

    NSLog(@"%@", error);
}
Run Code Online (Sandbox Code Playgroud)

但我得到这个错误:

Error Domain=NSCocoaErrorDomain Code=513 "The operation couldn’t be completed. (Cocoa error 513.)" UserInfo=0x175120 {NSFilePath=/var/mobile/Applications/D83FDFF9-2600-4056-9047-05F82633A2E4/App.app/sounds/Test Tones, NSUnderlyingError=0x117520 "The operation couldn’t be completed. Operation not permitted"}
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?谢谢.

iphone nsfilemanager

23
推荐指数
3
解决办法
3万
查看次数

标签 统计

iphone ×1

nsfilemanager ×1