I recently wanted to change jobs, and I was full of confidence, but I didn't know the weak points of my knowledge until the interview. So I started to learn runtime to address my weak points in interviews. The following will use my learning process to explain runtime, which is very important but also very broad. I hope it can help you who are confused. It can also serve as my own study notes. What is runtime? Runtime literally means running time, run (run, run) time (time). Everyone on the Internet calls it runtime. It is a set of relatively low-level pure C language APIs, belonging to a C language library, which contains many low-level C language APIs. It is the behind-the-scenes worker of OC. The OC code we usually write will be converted into runtime C language code during the running process. What is runtime used for? If you don't know runtime before, you may think it is useless, but it is actually very powerful. Let's unveil the mystery of runtime in the form of code. Function 1 Get all member variable names of a class (if your members are private, you can also get them) We create a new Person class, the .h code is as follows These member variables are all public. We can see them by clicking on the beginning file. If it is a system class, you may not know which members are in the class. You can easily solve this problem by using runtime. Now let's test it. Remember to add #import Printing Results You can try putting all members into the .m file, and the print result is the same. Function 2 Similarly, we can get all the attribute names of a class Print results: Function 3 Get all methods of a class Print results: We can see all the methods Function 4 Get all protocols followed by a class First comment out the protocol to be followed Test code Nothing was printed out. We open the code comments that follow Execute the test code again and print the results Isn't it great? You may think it's not very useful, so let's take a look at how to use runtime to archive and unarchive. Function 5: Archive/Unarchive The test is as follows Print results: Isn’t it much simpler than archiving and unarchiving before? The role of runtime is so important that I didn't know it until I learned it. This is my learning process and some experience today. I will continue to share my learning process with you in the future, hoping to give you some help. |
<<: Bad example: Five steps to make your website slow down
>>: Wild Dog Programmer Independence Day Rock Music Festival will be held on April 8
At 00:55 on December 27, 2021, after about 6 hour...
[[324038]] April 26th news: Recently, domestic iP...
[[258329]] Alipay Mini Program officially opened ...
Someone asked, a certain ice cream brand recently...
The robots that people imagine are the kind that ...
1. The account volume is unstable and the planned...
China Joy 2015 came as scheduled, and AnySDK made...
Snapshot is an indicator for us to measure the op...
A well-known brand of chocolate food has always b...
The course comes from Jack Ma’s short video accou...
[November 21, 2023, Hefei/Beijing] Volkswagen Gro...
This article adheres to If you don't understa...
Sony Z3 will be unveiled at IFA2014 on September ...
I got the internal data of China Mobile's mobi...
Nowadays, the demographic dividend is getting sma...