0
我想创建一个全局函数,所以我的核心数据类可以使用此函数来创建自定义setter。但我越来越`暧昧使用“willChangeValueForKey”自定义setter/getter函数核心数据
我正在使用的代码是:
func coredataSetter<T: NSManagedObject>(entity: T, attribute: CustomStringConvertible, value: String) {
entity.willChangeValueForKey(attribute.description)
entity.setPrimitiveValue(value, forKey: attribute.description)
entity.didChangeValueForKey(attribute.description)
}
我有点迷茫......