OBJECTIVE-C (category classification, informal agreement, classification extension)

Source: Internet
Author: User

Classification:

The main is to add some methods to the original class; You cannot add member variables

Person (person+eat)

Informal agreements:

The informal agreement is the category, that is, the category that is added to the class in the framework of NSObject or its sub-class foundation, is an unjust agreement

Write a category to NSObject, NSObject class name (EAT), NSObject subclasses can inherit the method inside

Classification (category) extension

Extended categories are also called Extensions of classes:

@interface person Category (empty)//class extension

{

You can add properties

int _age;

}

Expansion methods

-(void) eat; A relative private method

@end

cannot be implemented in @implementation person () @end

Implemented directly in the @implementation person @end

OBJECTIVE-C (category classification, informal agreement, classification extension)

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.