Writing high-quality Code-OC 6th Chapter inheritance and object-oriented design

Source: Internet
Author: User

41. Define the role of ISA in succession

  • 1, in Objective-c, each object is hidden a data structure ISA pointer
  • 2, the ISA pointer to the object's class, this class is also an object, has its own rights.
  • 3, in Objective-c, each object also retains a pointer to a superclass, through which the pointer can dispatch its own methods and scheduling base class.

42. Using categories and protocols to implement a mechanism similar to multiple inheritance

  • 1, categories, the implementation of the class-related methods of modularization, the different classes of methods assigned to different file.
  • 2, the class can overload the method of the original class, but it is not recommended to do so, the result is no longer access to the original method, if it is really overloaded, the correct choice is to create a subclass.
  • 3, and the ordinary interface is different, the implementation of the class file can not implement all the declared method, as long as not to call it.
  • 4, the agreement is a series of methods that do not belong to any tired list, wherein the declared method can be implemented by any class. Protocol (PROTOCOL) is not a real class, it can only declare methods and cannot add data.

43. Category and class extensions are continuation extensions of class inheritance.
44, inherit the implementation of the base class do not forget to call super.

  • 1. Call the base class method to use the services provided by this class.
  • 2. Override the method of the base class in order to introduce your own code into the defined program model.
  • 3. If you intend to supplement the behavior implemented by the base class, call Super.
  • 4. Do not call super if you intend to replace the behavior implemented by the base class.

Writing high-quality Code-OC 6th Chapter inheritance and object-oriented design

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.