【发布时间】:2025-12-21 00:10:12
【问题描述】:
我正在尝试创建一个全局函数,以便我的核心数据类可以使用此函数来创建自定义设置器。但我得到了'willChangeValueForKey'的模棱两可的使用。
我使用的代码是:
func coredataSetter<T: NSManagedObject>(entity: T, attribute: CustomStringConvertible, value: String) {
entity.willChangeValueForKey(attribute.description)
entity.setPrimitiveValue(value, forKey: attribute.description)
entity.didChangeValueForKey(attribute.description)
}
我有点迷茫……
【问题讨论】:
标签: swift function core-data nsmanagedobject