The paper

I recently collected and sorted out some iOS related questions, most of which are used by large companies or other people in interviews. They can be used in most interviews and daily work, and I hope you can use them to test yourself

Due to the large number of questions, this article only gives questions, I hope to give play to the practical ability of the circle friends, to explore yourself, you can also reply to your answers in the comments below or put forward higher quality questions!!

Runtime issues

Runtime is the core knowledge of iOS development, and if the following problems are solved, then you have a deep understanding of Runtime. Runtime is already open source. There is a source code for ObjC-Runtime that others have debugged and run. You can also find ObjC4 on objC4’s official website

Structural model

  1. Introduce the Runtime memory model (ISA, object, class, metaclass, structure storage information, etc.)
  2. Why design Metaclass
  3. class_copyIvarList & class_copyPropertyListThe difference between
  4. class_rw_tclass_ro_tThe difference between
  5. categoryHow is it loaded, both categoriesloadThe loading order of methods, and the loading order of methods with the same name for both categories
  6. category & extensionDifference, can I add Extension to NSObject? What’s the result
  7. Message forwarding mechanism, message forwarding mechanism and the advantages and disadvantages of other languages message mechanism comparison
  8. At the time of the method call,Method Query -> Dynamic resolution -> Message forwardingWhat did you do
  9. IMP,SEL,MethodThe differences and usage scenarios
  10. load,initializeWhat’s the difference between methods? What is the difference between them in inheritance
  11. Talk about the pros and cons of the message forwarding mechanism

Memory management

  1. weakThe implementation principle of?SideTableWhat is the structure of
  2. Application of associated objects? How does the system implement the associative object
  3. How are associated objects managed in memory? How does an associated object implement the weak property
  4. AutoreleasepoolThe principle of? What data structures are used
  5. ARCThe implementation principle of?ARCUnder theretain & releaseWhat optimizations have been made
  6. ARCWhat can cause a memory leak

other

  1. Method SwizzleMatters needing attention
  2. Attribute modifieratomicWhat is the internal implementation of? Is it thread safe
  3. What are some ways of introspection in iOS? What is the internal implementation
  4. Objc_getClass object_getClassWhat’s the difference?

NSNotification related

Read on and you can find the answer here.

  1. Implementation principles (structure design, how notifications are stored,name&observer&SELAnd so on)
  2. Are notifications sent synchronously or asynchronously
  3. NSNotificationCenterAre messages received and sent in the same thread? How do I send messages asynchronously
  4. NSNotificationQueueIs it sent asynchronously or synchronously? In which thread responds
  5. NSNotificationQueueandrunloopThe relationship between
  6. How do I ensure that the thread receiving the notification is in the main thread
  7. Does page destruction crash without removing notifications
  8. What happens when you add the same notification more than once? Multiple removal notifications
  9. Can the following methods receive notifications? why
// Send notification [[NSNotificationCenter defaultCenter] addObserver:self Selector :@selector(handleNotification:) name:@"TestNotification"object:@1]; / / receive notifications [NSNotificationCenter defaultCenter postNotificationName: @"TestNotification" object:nil];
Copy the code

Runloop & KVO

runloop

Runloop is not new to any standard iOS development. Familiarity with Runloop is standard. Here are a few typical issues

  1. How does the app receive touch events
  2. Why only the main threadrunloopIs open
  3. Why only refresh the UI on the main thread
  4. PerformSelectorandrunloopThe relationship between
  5. How do I keep threads alive

KVO

As with Runloop, this is standard, and also lists some typical problems

  1. Realize the principle of
  2. How do I manually shut down KVO
  3. Does modifying properties via KVC trigger KVO
  4. Under what circumstances will KVO crash, and how can it be protected
  5. Advantages and disadvantages of KVO

Block

  1. blockWhat does the structure look like
  2. Is a block a class? What are the types
  3. aintVariables are__blockThe difference between embellishment or not? Block variable interception
  4. blockIn the modifiedNSMutableArray, whether to add__block
  5. How does memory management work
  6. blockYou can usestrongModified?
  7. Why is it used to solve circular references__strong, __weakmodified
  8. blockhappencopyThe timing
  9. BlockOf the access object typeAuto variableWhen theThe ARC and MRCWhat’s the difference

multithreading

Mainly by the COMMUNIST Party of China

  1. iOSHow many types of threads are there in development? Respectively compared
  2. GCDWhich queues are available and which queues are provided by default
  3. GCDWhat are the method apis
  4. GCDRelationship between main thread and main queue
  5. How can synchronization be achieved in as many ways as possible
  6. dispatch_onceRealize the principle of
  7. When can a deadlock occur
  8. What types of thread locks are available and their functions and application scenarios are described
  9. NSOperationQueueIn themaxConcurrentOperationCountThe default value
  10. NSTimer, CADisplayLink, dispatch_source_tThe advantages and disadvantages of

View & image correlation

  1. AutoLayoutHow about the principle and performance
  2. UIView & CALayerThe difference between
  3. Event response chain
  4. drawrect & layoutsubviewsCall time
  5. UI refresh principle
  6. Implicit animation vs. display animation
  7. What is off-screen rendering
  8. Difference between imageName and imageWithContentsOfFile
  9. Will multiple images of the same image be reloaded
  10. When are images decoded and how are they optimized
  11. How to optimize image rendering
  12. If the GPU refresh rate exceeds the 60Hz refresh rate of the iOS screen, what is the phenomenon and how to solve it

Performance optimization

  1. How to do startup optimization, how to monitor
  2. How to do caton optimization, how to monitor
  3. How to optimize power consumption and how to monitor it
  4. How to do network optimization, how to monitor

Developer certificate

  1. What is Apple’s purpose in using certificates
  2. The app Store’s authentication process when installing an app
  3. How do developers install apps to devices in Debug mode

Architecture design

Typical source code learning

Just list some core iOS open source libraries, these libraries contain a lot of high quality ideas, source code learning must pay attention to each framework to solve the core problem is what, as well as their advantages and disadvantages, so as to really understand and absorb

  1. AFN
  2. SDWebImage
  3. JSPatch, Aspects(although one is not available and the other is not maintained, both libraries are neat and easy to learn)
  4. Weex/RN, the author thinks that this kind of front-end and client closely related library is must know its principle
  5. CTMediator and other Router libraries are common routing libraries, which are almost always used in development
  6. pleaseCircle of friendsAdd in the comments below

Architecture design

  1. Manual burying point, automatic burying point, visual burying point
  2. MVC, MVP, MVVMDesign patterns
  3. Common design patterns
  4. The disadvantages of singletons
  5. Common routing schemes, and comparison of advantages and disadvantages
  6. If the stability of the project is guaranteed
  7. Designing an Image Caching Framework (LRU)
  8. How to design agit diff
  9. Designing a thread pool? Draw your architecture diagram
  10. What is your app architecture, what are its strengths and weaknesses, why are you doing it, and how can you improve it

Other problems

  1. PerformSelector & NSInvocationAdvantages and disadvantages compared
  2. ocHow to implement multiple inheritance? How to face the section (can refer toDeep Parsing of Aspects -iOS section-oriented programming)
  3. What are thebugCan cause crashes, how to prevent crashes
  4. How to monitor crashes
  5. app(look at LLVM compilation, static linking, dynamic linking, Runtime initialization)
  6. Sandbox the role of each folder partition in the directory
  7. Briefly describes thematch-oFile structure

System basics

  1. The difference between processes and threads
  2. HTTPSHandshake process
  3. What is theMan-in-the-middle attack? How to prevent
  4. TCPThe handshake process? Why three handshakes, four waves
  5. Stack and heapDistrict differences? Who takes up more memory space
  6. Encryption algorithm:Symmetric encryption algorithm and asymmetric encryption algorithmThe difference between
  7. commonSymmetric and asymmetric encryptionWhat are the algorithms
  8. MD5, Sha1, Sha256The difference between
  9. charlesPacket capture process? Do not usecharles.4GHow does the network capture packets

Data structures and algorithms

For mobile developers, there are generally no very difficult algorithms, most of which are based on data structures. The author lists some necessary algorithms, of course, you can go to LeetCode to brush up problems when you have time

  1. Eight sorting algorithms
  2. The stack and queue
  3. String handling
  4. The list
  5. Binary tree related operations
  6. Deep search search
  7. Basic dynamic programming problems, greedy algorithms, binary search

conclusion

These are all collected by the author and some summary of my own interview experience, and will continue to be collected and supplemented in the later stage. Welcome the experts in the circle to post your answers or high-quality questions in the comment area or the public account

Preparing for interviews is one thing, but for iOS developers who are not interviewing, it’s better to test yourself and initiate progress. In addition, knowledge points are trivial, but can really understand all the trivial knowledge points and build up their own knowledge system, you upgrade.

Interested in the public account “code on work” real-time access to the latest high-quality articles, common progress. Access to dry goods resources (iOS, full stack full set of videos, machine learning & blockchain full set of videos)