gpt4 book ai didi

ios - 无法从乐观锁定失败中恢复

转载 作者:搜寻专家 更新时间:2023-10-30 20:16:31 26 4
gpt4 key购买 nike

我正在从我的模型中删除所有对象,但用户与之交互的某些对象除外。

删除后,我从 JSON 中获取那些保存的对象并更新它们的信息,当我保存 managedContext 时,应用程序崩溃并打印“无法从乐观锁定失败中恢复”。

我一直在寻找,但没有找到任何关于此消息含义的信息,知道吗?

谢谢。

最佳答案

Google 第一个结果,Apple 的文档。 (您到底在“寻找”哪里?)

Problem: You see the error message, "Could not merge changes".

Cause: Two different managed object contexts tried to change the same data. This is also known as an optimistic locking failure.

Remedy: Either set a merge policy on the context, or manually (programmatically) resolve the failure. You can retrieve the currently committed values for an object using committedValuesForKeys:, and you can re-fault the object (so that when it is next accessed its data values are retrieved from its persistent store) using refreshObject:mergeChanges:.

尽管错误消息不同,但这听起来很像您的情况,因为您很可能有多个上下文试图修改相同的对象。
尝试将合并策略设置为 NSMergeByPropertyObjectTrumpMergePolicyType

关于ios - 无法从乐观锁定失败中恢复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28152861/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com