0
我有一個類中有一個屬性的類,例如Car.Engine.Name。我已經實現了KVC,並想發送「Engine.Name」的WillChangeValue,但似乎沒有註冊。另一方面,爲Car.Name發送「Name」的WillChangeValue確實有效。關鍵路徑的WillChangeValue
Object target = _t;
PropertyInfo info;
for (int i = 0; i < keys.Length; i++) {
info = target.GetType().GetProperty (keys[i]);
if (i == keys.Length - 1) {
WillChangeValue (nsKeyPath); // <--- doesn't seem to work if there is a nontrival keypath
info.SetValue (target, nsValue.ToObject (info.PropertyType), null);
DidChangeValue (nsKeyPath);
} else {
target = info.GetValue (target, null);
}
}