What is runtime?
Runtimec also known as the runtime. is the system at the time of the operation of some mechanism.
is a set of underlying C language API(contains a lot of powerful practical C language data types,C language functions)
The OC code that we write usually turns into the runtime code at the bottom.
Such as:
Xqpersion *persion = [Xqpersion alloc] init];
[Persion Run];
At compile time, runtime will convert the above code into:
Objc_msgsend (Persion, @selector (run));
What's the use of Runtim?
Can dynamically generate, modify, delete a class, a member variable, a method.
can be get all the member variables inside a class, Method
Ivar * Class_copyivarlist: get all member variables inside a class
Method * Class_copymethodlist: Get all the methods inside a class
Method Class_getinstancemethod: Get an instance approach (object method, minus - start)
Method Class_getclassmethod: Get a class approach (plus + start)
Method_exchangeimplementations: A specific implementation of 2 methods of Exchange
What is Swizzle?
Calling a method in Objective-c is actually sending a message to an object, and the only way to find the message is by selector's name.
By using the dynamic characteristics of objective-c, the corresponding method of selector can be realized at runtime to achieve the purpose of linking to the method.
Each class has a list of methods that hold the mapping of selector's name and method implementation. IMP is a bit like a function pointer, pointing to a concrete method implementation.
Swizzle is the implementation of exchanging two methods while the program is running.
Ios--runtime/swizzle