【问题标题】:NSCocoaErrorDomain 513 on iOS8 devicesiOS8 设备上的 NSCocoaErrorDomain 513
【发布时间】:2014-11-22 20:21:58
【问题描述】:

我正在尝试使用

创建一个文件夹
BOOL status =[fileManager createDirectoryAtPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:pathComponent] withIntermediateDirectories:YES attributes:nil error:&error];

status 在 iOS7(设备和模拟器)、iOS8(仅限模拟器)中为 YES

但在 iOS 8 设备中,状态为 NO & 错误描述 = Operation couldn't be completed. Operation not permitted

[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:pathComponent 的值

在 iOS 7 中

/var/mobile/Applications/7AC7128C-1926-41AC-9108-4C85D0D75AE9/HelloWorld.app/../Library/Pages/CSS

在 iOS 8 中

/private/var/mobile/Containers/Bundle/Application/1E2D5D54-2585-4CB9-BD00-24C4BF873421/HelloWorld.app/../Library/Pages/CSS

为什么我只在 iOS8 设备中收到 Operation Couldn't be completed 错误?

【问题讨论】:

    标签: ios objective-c ios8 xcode6 nsfilemanager


    【解决方案1】:

    该代码应该在所有版本的 iOS 上都失败,因为您无法在应用程序包中创建文件/目录。

    您需要在应用文档、缓存等目录中创建文件。

    【讨论】:

    • 但它在 iOS 8 之前的所有其他设备上运行良好。
    • @TaruniNeema 这是未定义的行为,因为应用程序包一旦安装就不应被弄乱。
    猜你喜欢
    • 2013-04-12
    • 2016-01-27
    • 2021-04-14
    • 2019-03-23
    • 2014-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多