Interview summary of IOS senior engineer


Interview form: telephone interview

As a developer, it is very important to have a learning atmosphere and a communication circle. This is my ownIOS communication groupNo matter you are Xiaobai or Daniel, welcome to join us. Share bat, Ali’s interview questions, interview experience, discuss technology, let’s communicate, learn and grow together!

1. How do you usually solve the dependency of network requests: when the request of one interface depends on the result of another network request


  • Method 1: Thread: nsoperation operation dependency and priority
    [operationB addD ependency:operationA ]; // operation B depends on the operation
  • Method 2: Logic: activate the next network request in the response callback of the previous network request

How do you use RAC to solve different API dependencies

  • The scenario of signal dependence is that signal B will not be executed until signal a is executed. This is very similar to request dependence. For example, request B is executed only after request a is completed. We need to note that signal a must execute send completion signal, otherwise signal B cannot be executed
    //This is equivalent to the dependency in the network request. Signal a must be executed before signal B is executed
    //It is often used to execute one request before another
    //Note that signal a must execute send complete signal, otherwise signal B cannot be executed
    RACSignal * concatSignal = [self.signalA concat:self.signalB]
    //Here we are subscribing to this splicing signal
    [concatSignal subscribeNext:^(id x) {

3. How much do you know about compiling links

Analysis: this involves simple knowledge, can refer to

4. Briefly introduce the usage of KVO

Analysis: first of all, a brief introduction to the usage of KVO, first add observers, and then how to achieve a listening agent. As for the principle, we can use the knowledge of runtime to realize the principle of KVO. The author has implemented two forms of KVO, block and delegate, which can be referred to

The implementation of KVO is briefly summarized

When you look at an object, a new class is created dynamically. This class inherits from the original class of the object and rewrites the setter method of the observed property. Naturally, the overridden setter method is responsible for notifying all observed object values before and after the original setter method is called. Finally, the ISA pointer of the object (the ISA pointer tells the runtime system what the class of the object is) points to the newly created subclass, and the object magically becomes an instance of the newly created subclass.

It turns out that this intermediate class inherits from the original class. Not only that, Apple also rewrites the – class method in an attempt to deceive us that this class has not changed, that is, the original class. For more specific information, go to the code in Mike ash’s article, and you can understand it. I won’t repeat it here.

4. Programming problem: RLE algorithm, write a function to realize the function of counting the number of characters: for example, the input is aaabbccc, and the output is a3b2c3. No language.

Analysis: relatively simple, you can refer to this

5. Programming problem: please implement a function to judge whether a binary tree is symmetric. Note that if a binary tree is the same as its mirror image, it is defined as symmetric

Parsing: thinking, recursion, starting from the root node, judge whether the left and right child nodes are symmetrical, if symmetric, recursive, if asymmetric, return No.