Dynamic type dynamic binding dynamic loading

Source: Internet
Author: User

1. Dynamic type
The runtime only knows the type of the object, the dynamic type is very common in programming, the simple is that the ID type, such as the agent at the time of the custom, ID type. At the moment we sometimes set our own methods, unsure, what type of object is passed in, we also ID type, and then inside the method to determine the type

2. Dynamic binding
When an object is instantiated, the object type is determined, and the object's properties and response methods are also determined. This is dynamic binding. White that is, when the object is determined, the corresponding properties and methods are bound. Then we can also dynamically to the object to add and implement methods. Class_addmethod and Method_setimplementation methods

3. Dynamic loading
As needed to load the required resources, for example, the retina screen above the image load @2x, two ordinary screen loading is the original

Run-time features Objective-c soul
OC many will be converted to the corresponding runtime method after compiling
1. In peacetime quite to use relatively little, but some tricky problems, with this, will be easy to solve.
1. Give one or two examples!!! If we want to encapsulate a database through fmdbase, and want to pass in any type model, I can create the corresponding database table and add, delete and so on. At this time, we can use, this OC running characteristics, dynamically get the properties of the object. The table is then created by stitching the strings with attributes.
2. In an example, KVO's underlying implementation, there is a dynamic creation of a class that inherits the object being listened to, and then overrides the setter method, changing the ISA pointer to point to the effect of being reached and listening.

Dynamic type dynamic binding dynamic loading

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.