Objective-C note 2-

Source: Internet
Author: User

1 category

Classification provides a way to extend the class definition. Classification can access the instance variables of the original class. Pay attention to the following points when using classification:

1.1 you cannot add any variables of the category. If you want to add variables, consider creating them.

1.2 another method in this class can be reloaded for classification, but please do not try this. That is, Do not overload another method in the override class in the category.

1.3 A class can have many categories.

1.4 The Methods declared in classification can not be implemented in implementation. (Can be implemented later)

1.5 classification can also implement protocols, such as @ interface fraction (stuff) <nscopying, nscoding>

2 protocol

The Protocol is the interface in other languages. Objective-C 2.0 adds the optional keyword to the Protocol, indicating that this method is optional. This replaces informal protocols.

Informal Protocol: it is actually a classification, listing a group of methods, but not implementing them. Sometimes informal protocols are also called abstract protocols.

ID <nscopying, nscoding> currobj

This statement tells the compiler that currobj will contain objects that comply with the nscopying and nscoding protocols. If not, a warning will be given.

3 type conversion

4. PreprocessingProgram

5 Scope

Related Article

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.