Interview format: Telephone interview

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

Resolution:

  • Option 1: Thread: NSOperation Operation dependency and priority
[operationB addDependency:operationA]; // Operation B depends on operationCopy the code
  • Option 2: Logic: Activate the next network request in the response callback of the previous network request

2. How have you applied RAC to resolve different API dependencies

  • Signal dependence

The usage scenario is that signal B will be executed only when signal A is finished, which is similar to the dependency of request. For example, request B will be executed only after request A is completed. We need to pay attention to the fact that signal A must execute and send the completed signal, otherwise signal B cannot be executed

RACSignal * concatSignal = RACSignal * concatSignal = RACSignal * concatSignal = RACSignal * concatSignal = [self.signalA concat:self.signalB]; [concatSignal subscribeNext:^(id x) {NSLog(@"%@",x);}];Copy the code

3. Compile links to see how much you know

Analytic: this involves simple knowledge, may refer to www.360doc.com/content/17/…

4. Briefly introduce the usage of KVO

KVO = KVO = KVO = KVO = KVO = KVO = KVO Knowledge about principle, can use the runtime implement KVO principle, the author once KVO block and delegate two forms, may refer to www.jianshu.com/p/c1aa85779…

A brief overview of the implementation principle of KVO:

When you observe an object, a new class is created dynamically. This class inherits from the object’s original class and overwrites the setter methods for the property being observed. Naturally, the overridden setter method is responsible for notifying all observed object values of changes before and after the original setter method is called. Finally, the isa pointer to the object (which tells the Runtime system what the object’s class is) points to the newly created subclass, and the object magically becomes an instance of the newly created subclass.

It turns out that this middle class inherits from the original class. Not only that, But Apple has overwritten the -class method in an attempt to trick us into thinking that the class is the same. For more information, run through the code in Mike Ash’s article, which I won’t repeat here.