KVC
KVC (key-value-coding, key value code)
Assign a value to a property: value Forkey: The name of the property
KVC is an embodiment of the OC language Dynamic runtime mechanism, and any object of the NSObject type supports KVC
KVO (key value observation) (Key-value-observer)
: Observation of variables that conform to KVC key value coding, mainly on the operation of variable assignment
[_model addobserver:self forkeypath:@ "Price" options:nskeyvalueobservingoptionnew| Nskeyvalueobservingoptionold Context:nil];
Functions to be implemented by key-valued observers
The first parameter is the object property name of the listener.
The second parameter listens to the object
The third parameter changes the content if you set the Nskeyvalueobservingoptionnew, you can get the new value of the object property.
If you set Nskeyvalueobservingoptionold, you can get the old value of the object property
-(void) Observevalueforkeypath: (NSString *) KeyPath Ofobject: (ID) object change: (nsdictionary *) Change context: (void *) context{
}
KVC and KVO