【发布时间】:2019-05-03 13:12:53
【问题描述】:
我想通过删除关系中的一些对象来更新我的核心数据对象。
我知道 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 }
)
【问题讨论】:
标签: ios swift core-data corestore