As a developer, it’s especially important to have a learning atmosphere and a networking community, and this is one of my iOS development networking groups:130595548, whether you are big ox or small white are welcome to enter, let us progress together, common development! (The group will provide some free study books collected by the group owner and hundreds of interview questions and answers documents for free!)

1. The algorithm

(1) Please find the largest 1000 numbers in the 10 million integer data as fast as possible?

This is a frequently asked question, Baidu online solution is also a lot of.

Here is just the basic idea for reference: divide 10 million integer types into appropriate N files on average, find the largest number of the first 1000 for each file respectively, and finally merge the first 1000 data of each file with the conventional algorithm.

So how do you find the top 1,000 largest numbers in each file?

Then read the next number from the file and compare it with the first number in the array. If it is larger than the first number in the array, replace the first number in the array and reorder the number. Then take the next number for the next round of comparison.

(2) Circular list problem: an ordered circular integer list breaks, please insert an integer number, so that the list is still ordered.

Baidu, please… Ha ha.

2. The OC

(1) Can Block modify global variables, global static variables, local static variables?

The answer, yes. For the reasons, see an in-depth study of Block capturing external variables and the implementation of __block

(2) Code analysis question, what is the output result of the following code?

@property (nonatomic, strong) NSString *strongString;
@property (nonatomic, weak)   NSString *weakString;

strongString =  [NSString stringWithFormat:@"%@",@"string1"];
weakString =  strongString;
strongString = nil;

NSLog(@"%@", weakString);
Copy the code

Answer: string1, cause: @”string1″ initialize retainCount == 1; StrongString points to @”string1″ object, retainCount +1, strongString = nil, retainCount -1, and finally retainCount == 1, so string1 is the output.

Sorry, I gave you the wrong direction before.

(3) What is the realization principle of SDWebImage? How does it solve the problem of image confusion in tableView reuse?

[self sd_cancelCurrentImageLoad] in UIImageView+WebCache file will be called every time.

(4) What is the iOS event response chain mechanism?

Answer: iOS event response chain

(5) There are transverse arrangement of Label1 and Label2 in Figure View. The spacing of Label1 and Label2 is fixed, and the content changes dynamically. Please use AutoLayout to establish constraints, ensure that label2 content is fully displayed, label1 content adaptive?

Answer: Please refer to the iOS AutoLayout usage tips

(6) How about Runtime and Runloop?

6.1 Runtime: Runtime is a set of low-level C language apis. Runtime application scenarios:

A. Automatic transformation of dictionary model (MJExtension,YYModel)

B. System method Interaction (Swizzle Black Magic)

C. Universal controller jump (by pushing the controller name, properties, etc.)

D. add attributes to categories (categories) (implement setter, getter methods)

E. Automatic archiving and archiving (similar to a)

6.2 runloop: literally a runloop with a do-while loop inside which various tasks are processed. Each thread has one runloop. The main thread’s loop starts by default, and the child thread’s runloop must be started manually (by calling the run method). Runloop can only select one Model to start. If there is no Source(Source0, Source1) or Timer task in the current Model, exit runloop. With Runloop, you can save Cpu resources and improve application performance by keeping things running and not resting.

Runloop application: a.

For a more in-depth understanding of Runloop, see The Daniu blog for an in-depth understanding of Runloop.

Or watch this video to share RunLoop offline on iOS by Sunyuan @sunnyxx

3. The Swift

(1) Struct and class?

The answer:

The difference between:

A. Classes can inherit, but structs cannot

B. An instance of a class can be de-initialized to free up storage space

C. The objects of a class are reference types and the structures are value types. So class assignments pass references and structs pass values.

Similarities:

A, both classes and structures can be extended

B, define attributes to store values

C, define methods to provide functionality

D, define subscripts to access values through subscript syntax

E, define initializers used to generate initialization values

(2) class and staITC keyword difference?

A. Static can be used in a class, structure, or enumeration. Class can only be used within a class.

B. Static modifies storage properties. Static modifiers are called static variables (constants). Class does not modify storage properties.

C. Static modified computed properties cannot be overridden. The class modifier can be overridden.

D. static methods cannot be overridden. Class methods can be overridden.

When an e. class modified computed property is overridden, you can use static to make it static. When an f. class modified class method is overridden, you can use static to make the method static.

(3) How does SWIFT solve the problem of circular reference?

Answer: Please refer: Unowned or Weak? Life cycle and performance comparison

4. Performance optimization

Do you know about App performance optimization? What are the factors that affect App startup time?

Answer: 1.1 App performance optimization involves many aspects. As a developer, I want to know how well I know and use Instruments’ Time Profiler tools

Zombies: Detects zombie objects

Allocations: Memory check

Leaks: Detects memory Leaks.

1.2 Factors responding to App startup time are generally divided into pre-main (time before App Main function is executed) and main (time before App Main function is executed). For detailed analysis, please refer to [iOS] an instant startup time optimization

As a developer, it’s especially important to have a learning atmosphere and a networking community, and this is one of my iOS development networking groups:130595548, whether you are big ox or small white are welcome to enter, let us progress together, common development! (The group will provide some free study books collected by the group owner and hundreds of interview questions and answers documents for free!)