concept

Objective-c is a dynamic language based on C with object-oriented features and message forwarding mechanisms. This means that it requires not only a compiler, but also a Runtime system to dynamically create classes and objects to send and forward messages.

Any code we write will be converted to Runtime C code for execution as the program runs, such as [target doSomething]; Will be converted to objc_msgSend(target, @selector(doSomething)); .

Everything in OC is designed to be objects. We all know that a class is initialized to an instance, and that instance is an object. In fact, a class is essentially an object, represented in Runtime as a structure.

Runtime is the bottom layer of OC, which is a set of pure C apis. So speaking of which, OC can run code and Runtime can certainly run, and runtime can run programs that don’t necessarily run under OC.

As a developer, it is especially important to have a learning atmosphere and a communication circle. This is my iOS communication group: 711315161. No matter you are a small white or a big bull, welcome to join us.

Why should you be familiar with The Runtime mechanism?

Is Runtime often used in real life development? The answer is yes. But Runtime is not good to use the degree of understanding, understanding good code quality efficient and practical; If you don’t use it well, it’s easy to make your own pits. In actual development, I am not recommending that you be familiar with the underlying things flexibly, but that you be familiar with the underlying mechanisms. Or it has encapsulated a nice and easy to use API.

What is Runtime used for?

For example, dynamic adding properties, dynamic adding methods, method exchange, dictionary model transformation

Refer to the article: www.jianshu.com/p/6fd68ac84…