KVC and KVO

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.