是否可以通过一行代码从一对多关系中删除所有托管对象,而无需循环托管对象?这是下面的“好”解决方案吗?
u.cars = NSMutableOrderedSet()
最佳答案
使用NSObject
的KVC方法mutableSetValue
u.mutableSetValue(forKey: "cars").removeAllObjects()
或者如果 cars
是有序集
u.mutableOrderedSetValue(forKey: "cars").removeAllObjects()
关于ios - 如何从一对多关系中删除所有托管对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45049396/