gpt4 book ai didi

ios - CoreStore 通过事务删除对象来更新关系。编辑不起作用

转载 作者:行者123 更新时间:2023-11-28 13:41:31 31 4
gpt4 key购买 nike

我想通过删除关系中的一些对象来更新我的核心数据对象。

我知道 CoreStore 提供了很少的更新和删除方法。我的问题是我可以使用更新功能删除吗?

let john: MyPersonEntity ...
jane.removeFromFriends(john) // Removing john form NSSet

CoreStore.perform(
asynchronous: { (transaction) -> Void in

let jane = transaction.edit(jane)! // Assuming that this is a proxy and context will be saved with no john.

},
completion: { _ in }
)

或者我是否需要从关系中删除这样的 john。

let john: MyPersonEntity = jane.getJohnObject() // Returns john object from NSSet.

CoreStore.perform(
asynchronous: { (transaction) -> Void in
transaction.delete(john)
},
completion: { _ in }
)

最佳答案

简而言之,不,因为 John 是一个实体。约翰需要被删除。如果关系使用默认的无效规则,则无需进一步操作。

关于ios - CoreStore 通过事务删除对象来更新关系。编辑不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55970571/

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