【问题标题】:Unable to delete UIManagedDocument using NSFileCoordinator无法使用 NSFileCoordinator 删除 UIManagedDocument
【发布时间】:2016-05-22 20:27:12
【问题描述】:

我已修改 Apple 的 Lister 示例以使用 UIManagedDocument 而不是 UIDocument。除了删除文档外,一切正常。当我尝试使用ListUtilites.swift 中的removeListAtURL 方法中的Apple 代码删除文档时,该代码使用NSFileCoordinator,在列出的文档消失然后重新出现在模拟器中后,我收到此错误消息:

CoreData: error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///Users/.../AppGroup/E16FD6E8-8AD6-44BB-A031-5FB497F04FD4/Documents/myList.list/StoreContent/persistentStore options:{
    NSPersistentStoreRemoveStoreOnCleanupKey = 1;
} ... returned error Error Domain=NSCocoaErrorDomain Code=134080 "(null)" UserInfo={NSUnderlyingException=Can't add the same store twice} with userInfo dictionary {
    NSUnderlyingException = "Can't add the same store twice";

“不能两次添加同一个商店”错误对我来说没有任何意义,因为我正在删除文件。也许我需要先关闭文件?该文件是本地的,而不是在 iCloud 中,所以我认为我不需要删除任何事务日志。此外,当我删除 NSFileCoordinator 代码时,它可以正常工作,用户 NSFileManager 马上就可以正常工作,但对于 iCloud 文件我会遇到同样的错误。

【问题讨论】:

    标签: ios core-data icloud uimanageddocument nsfilecoordinator


    【解决方案1】:

    我忘了先关闭文档。记住孩子们,在删除它们之前总是关闭你的文档......尤其是UIManagedDocuments。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-19
      • 1970-01-01
      • 2012-08-01
      • 2013-10-16
      • 1970-01-01
      • 2016-03-27
      • 2013-07-02
      • 2016-07-31
      相关资源
      最近更新 更多