CoreData批处理请求错误Swift

时间:2017-10-21 04:05:49

标签: ios swift core-data

我在尝试执行批量删除时失败了,我无法弄清楚发生了什么。

我致电请求:

self.deleteAllRecords(entity: self.someEntity)

,功能是:

func deleteAllRecords( entity : String)
    {
        let delegate = UIApplication.shared.delegate as! AppDelegate
        let context = delegate.persistentContainer.viewContext


        let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: entity)
        let request = NSBatchDeleteRequest(fetchRequest: fetch)

        do {
            let result = try context.execute(request)
            print("result: ", result)
        }
        catch {
             print ("There was an error 1")
        }
        do {
            try context.save()
        } catch {
            print ("There was an error 2")
            }

    }

我因错误而挂断了。感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

Seam3目前不支持vm.temp操作,因此会引发NSBatchDeleteRequest错误。