CoreData读/写操作,增加了“ Documents and Data”文件夹的大小

时间:2018-10-23 13:08:23

标签: ios swift core-data

当我进行初始同步时,数据已正确存储到数据库中,并且占用了Documents and Data文件夹中的某些磁盘空间。但是,如果我再次进行同步,它将继续增加Documents and Data中的磁盘空间(从服务器下载的相同数据)。在网上搜索时,我发现有一个auto-vaccum可以释放磁盘空间。甚至无法正常工作。

do {

    let options = [NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true, NSSQLiteManualVacuumOption: true]
    try coordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: storeURL, options: options)
    var values = URLResourceValues()
    values.isExcludedFromBackup = true
    try storeURL.setResourceValues(values)

} catch {

    if let confirmedError = self.moveIncompatibleStoreFromURL(storeURL) {
        preconditionFailure(confirmedError.localizedDescription)
    } else {
        return self.dataManagerPersistentStoreCoordinator
    }

}

有帮助吗?

0 个答案:

没有答案
相关问题