Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Swift-核心数据:DestroyPersistentStore自然抛出错误_Ios_Swift_Core Data - Fatal编程技术网

Ios Swift-核心数据:DestroyPersistentStore自然抛出错误

Ios Swift-核心数据:DestroyPersistentStore自然抛出错误,ios,swift,core-data,Ios,Swift,Core Data,我想在我的应用程序中有一个选项来重置我的所有数据。我创建了一个名为CoreDataStack的类,并使用此函数将我所有的核心数据代码放入其中: func dropAllData() throws { try persistentStoreCoordinator.destroyPersistentStoreAtURL(applicationDocumentsDirectory, withType:NSSQLiteStoreType , options: nil) t

我想在我的应用程序中有一个选项来重置我的所有数据。我创建了一个名为
CoreDataStack
的类,并使用此函数将我所有的核心数据代码放入其中:

func dropAllData() throws {
    try persistentStoreCoordinator.destroyPersistentStoreAtURL(applicationDocumentsDirectory, withType:NSSQLiteStoreType , options: nil)        
    try addStoreCoordinator(NSSQLiteStoreType, configuration: nil, storeURL: applicationDocumentsDirectory, options: self.options)
}
然后,我在我的
AppDelegate
中有此函数:

func dropTables() {
    do {            
        try stack.dropAllData()
    } catch {
        print(error)
    }
}
我以前使用过这个函数成功地删除了我的数据,但突然我无法删除任何内容,当我调用
dropTables()
时,我一直收到这个错误

错误域=NSCOCAERRORDOMAIN代码=134000“(空)”用户信息={NSURL=file:///Users/myname/Library/Developer/CoreSimulator/Devices/59E4B2FB-E0E4-4527-8793-253864A2DE83/data/Containers/Data/Application/33D1C5CF-94B8-4897-A77F-A10DDFEF92D6/Documents/}


我试着搜索这个错误,但什么也找不到(或者我只是找错了地方)。我还试着从设备上删除应用程序,重新安装,然后再试一次,但得到了相同的结果。有人知道这个错误是什么吗?为什么不能删除我的数据库?

你应该删除所有记录,而不是删除表。。。!!“134000”是一个
NSPersistentStoreInvalidTypeError
-请参阅。它看起来像是
applicationDocumentsDirectory
指向应用程序的
Documents
目录,而不是SQLite文件?