"Reading notes" IOS-KVC

Source: Internet
Author: User

One, KVC is the key/value code.

Second, the basic invocation of KVC includes-valueforkey: and-setvalue:forkey:.

Third, for Kvc,cocoa automatically put and remove scalar values. That is, when Setvalueforkey is used, it automatically places scalar values (Int,float and structs) into NSNumber and Nsvavlue, and when-setvalueforkey is used, it automatically takes a scalar value out of those objects. Only KVC has this automatic packing function. General method calls and property syntax do not have this capability.

Four, KVC is not free.

KVC can handle collections very easily. So why not use KVC to process all objects, and discard access methods and code writing? There's no free lunch unless you work for a big tech company in Silicon Valley. KVC needs to parse the string to calculate the answer you need, so it is slow and the compiler is not able to check it incorrectly. You may want to handle [email protected]:, but the compiler cannot tell if it is the wrong key path. Therefore, when you try to use it, a run-time error occurs.

Reference: "Objective-c Basic Course"

  

"Reading notes" IOS-KVC

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.