IOS uses categories category and extension extension

Source: Internet
Author: User

In OC, the classes in the library can be extended on an original basis.

For example, to add new attribute variables and methods to nssting, you can create a new. m file in Xcode

Select the corresponding original class

Then you can select the extension or classification, the classification will be automatically connected with the + number, the extension will automatically connect with _, such as

"Nsstring+security.h"

"Nsstring_extension.h"

The extension can add attribute variables and methods, but only adds a new header file

Categories can add methods, cannot add attribute variables, have a header file and a. m file, and M files can implement specific methods

So in the classification of reference to the extension of the header file, you can do a method of a class of property variables to add, and in the M file can be implemented in specific ways

IOS uses categories category and extension extension

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.