iOS development-method call process at run time

Source: Internet
Author: User

Procedure at run time for method invocation

If an instance method is invoked with an instance object, the instance's Isa pointer points to the object (that is, the class object) operation.

If a class method is called, it is manipulated in the object that the ISA pointer to the class object points to (that is, the meta-class object).

  1. First, the method to invoke is found in the list of cached methods in the corresponding action object, and if found, turn to the corresponding implementation and execution.

  2. If not found, find the method in the method list in the corresponding action object, and if found, turn to the corresponding implementation

  3. If not found, go to the object that the parent pointer points to.

  4. And so on, if the root class hasn't been found yet, turn to intercept call.

  5. If there is no way to rewrite the interception call, the program error.

The above process brings me the inspiration:

  • Overriding the method of the parent class does not overwrite the parent class, except that the method is found in the current class object and will not be found in the parent class.

  • If you want to invoke the implementation of the parent class of a method that has already been overridden, simply use the Super compiler identifier, which skips the process of finding a method in the current class object at run time.

Source: http://www.cocoachina.com/ios/20150901/13173.html

iOS development-method call process at run time

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.