Inheritance and Categories

Source: Internet
Author: User

Inherit application: There are several classes when they have some common properties, they can declare a parent class, inherit it. Simplify the code.

Category:

1, which can be used to write code in chunks.

2, expand some system classes. Super powerful.

3, some common methods can be extracted into the nsobject category, because all classes inherit from NSObject, so all classes will have this method, can simplify the code. Generic, add a category to the parent class, and there will be methods in the category in all subclasses.

Common denominator: All can simplify the code. Categories can be added as inheritance.

Inheritance and Categories

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.