"Remit" The question on the iOS face

Source: Internet
Author: User

1. What is the description category (categories) and extension (extensions) respectively? And the difference between the two? What is the difference between inheritance and category in implementation? Why can category only add methods to objects, but cannot add member variables?

A: Consider the advantages of class than inheritance

Class is to spread the implementation of the classes into different files and to extend the new method to the class

Extension is the addition of a private method to a class that is used only for the class that it sees

Inheritance can extend instance variables and categories cannot

Categories if you can add member variables, it's no different than inheritance. And in-line project updates to maintain project stability with category pen inheritance

"Remit" The question on the iOS face

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.