It has been more than 6 years since I entered the ranks of iOS development in 2015. I have been defining myself as a UI boy. I have not paid attention to learning and accumulation at normal times. I haven’t studied the bottom, so I’m a frog in a well. I didn’t summarize my blog, I didn’t upload my code to GitHub. I felt I had lost my competitiveness as I got older in this increasingly competitive environment. It’s true, just one year of experience, repeated for seven years. Recently, DUE to personal reasons, I left my job again. I feel that I need to prepare for some time to summarize my knowledge and make a memo for myself, so that I can recover the interview status as soon as possible in the subsequent interview. Today, I’ll start with an index, listing the things I can think of first. If you have time, you should make a framework of knowledge, which may be of great help to memory and understanding.
The cornerstone at the bottom of OC
-
Objects, class objects, metaclass objects, and the relationships among themCopy the code
This is the most important foundation for many things, such as the alloc/dealloc call stack. To operate on an object, you need to know enough about the structure of the object to understand why the function is called and what the function is used for. For example, in Runtime, the operation of the object (the acquisition of properties, methods, etc.) and method hook are also based on the operation of the object, which part of the content of the object is operated. There is also a method call to the underlying objc_msgSend, message forwarding mechanism, how to find the CORRESPONDING IMP through SEL also requires a sufficient understanding of the internal structure of the object. KVO, KVC, category, etc., are also related to objects. Another very important content is the bottom layer of the BLock, which is also closely related to the object, so the object runs through the whole bottom exploration process and knowledge system. You must have a good knowledge of the object. I was also thinking that this series of blogs, objects to be interspersed throughout the series, and then a summary at the end of the series.
-
runtime Copy the code
About Runtime, this needless to say, OC is a very dynamic language, and the implementation of dynamic, is to rely on Runtime to achieve. Runtime is one of those low-level dark magic that you don’t often use. The message forwarding mechanism, method substitution, method exchange, KVO, etc. of OC are all implemented by Runtime, which is described in the Runtime section. Runtime is powerful, but it still needs to be used in a project. It is not enough just to know how powerful it is. This time, I will intentionally find a common, easy to use runtime use case and practice it myself (show.jpg, in fact, I just know, but not too much practice).
-
runloop Copy the code
Runloop, I believe many people have the same feeling with Runtime, is also a very low-level thing, in the actual development, less contact. In my humble opinion, Runloop is a resource-saving solution that enables the CPU to process events when there are events and sleep when there are no events, i.e. switch from kernel mode to user mode, or from user mode to kernel mode. The runloop, which is also the main thread, is always started to ensure that the application does not exit. This is also the basis for many knowledge points, including but not limited to NSTimer, thread preservation, CADisplayLink, AutoreleasePool, and more. So, this is also very important knowledge.
OC is based on cornerstone knowledge at the bottom
In the middle of writing, I found that many knowledge points have been mentioned in the above article, in fact, it is nothing more than those things, here, I am a little nonsense, they are listed again (pit ah, the original blog is not a simple thing, write a running account is simple, write good, difficult!) . This also covers more than 80% of the knowledge in the interview. Well, I’ll just list some common interview questions at the end of the lecture, and then answer them in a subsequent article (so this article may change from time to time, after all, you don’t have to jump into a hole, you can fill it in secretly).
-
Knowledge of OC objects
A, the relationship between OC objects, class objects and metaclass objects B, what is the ISA pointer used for? C, what are the keywords used in daily life? D, do you know the Nonpointer? E. What did Delloc do? F. How does automatic reference counting work? G, the difference between class_rw_t and class_ro_t h, etc., etc., too manyCopy the code
-
KVO
A, the realization principle of KVO? B. Manual call of KVO?Copy the code
-
KVC
A, what are the underlying methods of KVC call? B. Has it ever been used in actual development? How does it work?Copy the code
-
The Category and Extention
A, Category and Extention? B, Category implementation principle? B. Can Category add attributes to a class? If not, how can I add it?Copy the code
-
Block
A. What is your understanding of block? B, describe the variable capture mechanism of block, why there is this mechanism? C, there are several types of block, what is the relationship between them? D, what is the key to using block? E. Have you ever encountered the problem of circular reference? How to avoid it? Do you know NSProxy? If you implement an intermediate object, what's the idea? How is it different from NSproxy? F, List these first, too many, tired.Copy the code
-
runtime
A, what do you know about Runtime? B, What can Runtime do? What have you ever done with it yourself? C, what is method swizzing? D, how does Runtime find the corresponding IMP address by selectorCopy the code
-
multithreading
A. How many ways to realize multithreading? What's the difference? B, how to implement multiple read and single write C, the relationship between queue and thread D, how to process multiple asynchronous multi-threaded requests uniformly after all the requests are completed? E. Do you know the possible problems of NSTimer? How to solve the problem? F. Encapsulate a timer with GCD. What is the idea? G, tiredCopy the code
-
runloop
What is the concept of runloop? B. How many events, how many modes, and how many stages does a runloop have? C. Do you understand the principle of automatic release pool? When was it released? D. What does Runloop do when the user clicks a button? It may lead to questions about the response chain, the delivery chain (e), how to keep a thread from exiting (f), questions related to performSelector afterDelayCopy the code
The above information is not finished to continue, rest, when you want to update.
All right. Above is what I wrote about the OC bottom principle summary series of the beginning, the next is to enter the specific knowledge link, I hope I can seriously sum up again, this series as a memo, each interview, take a look at it, and successfully win more offers. Above think ~