次のコードがあります
protocol JsonParseDescriptor {
//some required methods
func parsePrimitives() {
}
extension JsonParseDescriptor where Self: NSManagedObject {
func parsePrimitives() {
self.setValue(1, forKey: "id") //this throws an error in swift stating Ambiguous use of setValueForKey
self.setValue(1, forKey: "id") //this does not throw any compile-time error
}
}
setValue:ForKey: がこのエラーを引き起こしている理由はありますか? 興味深いことに、setValue:ForKeyPath: はこの問題の原因ではありません。副作用が発生し、setValue:ForKey 以外で機能する場合に備えて、後者を使用することを恐れています。アイデアはありますか?