Categories, extensions and agreements in OC

Source: Internet
Author: User

Category: Also called classification, category.

* is for class extensions without source code

* The expanded function becomes part of the original class and can be called directly from the original class or object of the original class, and can inherit

* This method can only extend the method, cannot expand the instance variable

* The added class is a pair of. h. m files, the file name is the original class name + the classification name

Extension: Extension

* Add private instance variables and methods for classes that can get the source code

* Note: The class that extends the operation is the class that can get the source code (the class with the. m file)

* The method defined by the extension is private, and the outside world is not accessible, only in the. m file of the current class.

* Equivalent to writing the category. h file in the. m file of the original class, only the. h file

Protocol: This is a way of indirect expansion of the protocol, there are only a bunch of methods of declaration, the use of the Protocol, the implementation of the method in the protocol to expand the function, but only to expand the method, can not expand the instance variable. Limited to the source code that must have the class.

Categories, extensions and agreements in OC

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.