You should be busy job-hopping and interview recently, after all, gold, silver and silver, cherish the opportunity, I wish all of you successfully pass the interview, welcome the offer of Dachang. You can chat privately if you need information. I understand
What happens from the input URL to the presentation of the page
- 1. Enter the address
- 2, Browser to find the domain name IP address
- 3. The browser sends an HTTP request to the Web server
- 4. Permanent redirect response from the server
- 5. The browser tracks the redirect address
- 6. The server handles the request
- 7, The server returns an HTTP response
- 8. The browser displays HTML
- 9. Browser sends requests for resources embedded in HTML (such as images, audio, video, CSS, JS, etc.)
IOS high frequency (basic + bottom) interview questions
What timers do you use most often in your development process, and are there any discrepancies in timers, and if so, why?
In iOS, NSTIMER, CadisPlayLink and GCD timer are often used. NSTIMER and CadisPlayLink are implemented based on NSRunLoop, so there are errors. GCD timer only relies on the system kernel, which is more punctual than the first two.
The reason for the error is: It is related to the NSRunLoop mechanism, because the RunLoop will check whether the current accumulated time has reached the interval time set by the timing after each lap. If not, the RunLoop will enter the next round of task and check the current accumulated time after the task is finished. At this time the cumulative time may have exceeded the interval time of the timer, so there will be errors.
Is a block a class? What types are there?
Block is also a class because it has an isa pointer. The types of block
- _NSConcreteGlobalBlock is set as a global variable in the program’s data area (.data)
- _NSConcreTestackBlock on the stack (all blocks on the stack)
- _NSConcreteMallocBlock heap
This ISA can be run bit by bit
__block () __block () __block () __block ()
- Blcok is divided into global blcok, heap block and stack block.
- Under MRC: As long as no external variable is accessed, it is a global block. Accessing an external variable, which is the stack block. The explicit call to block copy is the heap block.
- Under ARC: As long as no external variable is accessed, it is a global block. If an external variable is accessed, it is stored in the stack before accessing the external variable, and in the heap after accessing the external variable.
- __block () changes the value of an external variable from a value to a pointer, so that the value of an external variable can be retrieved and changed. Also, changes to external variables affect the output of the block function.
-
Block circular reference problem: When an object of a class holds a block that references the object inside the block, it is a circular reference relationship. You can remove the circular reference using the strong-weak-dance method.
What is the difference between shallow and deep replication?
Answer: Shallow copy: Just copy the pointer to the object, not the reference object itself. Deep replication: Copies the reference object itself. It means that I have A object, get A_copy object after A copy, for shallow copy A and A_copy point to the same memory resources, copy of just is A pointer, the object itself Or is it just A, that if we are to modify A_copy performed operation, then find A reference object is modified, This actually goes against one of our ideas about copying. Deep copy makes sense because there are two separate copies of the object itself in memory. To use a popular phrase on the Internet, it would be: shallow copy is like you and your shadow, you’re finished, your shadow is finished, too. Deep copy is like you and your clone, you’re finished, your clone is still alive.
Those who want to receive free information can enter the dress or add a friend to get it, here is one
IOS communication circle:
710 558 675You can see,
Share the BAT.
Ali Interview Questions,
The interview experience.
To discuss technical, skirt information directly download on the line, we exchange and learn together!
What is the role of categories? What is the difference between inheritance and class implementation?
A: Category can add new methods to it without knowing or changing the original code. It can only add, not remove, changes. And if there is a name conflict between a class and a method in the original class, the class overrides the original method, because the class has higher priority. Categories serve three main purposes:
- (1) Scatter the implementation of the class into several different files or several different frameworks.
- (2) Create a forward reference to a private method.
- (3) Add an informal protocol to the object. Inheritance can add, modify, or remove methods, and it can add attributes.
What is the difference between a protocol in OC and an interface concept in Java?
A: The OC agent has two meanings, officially defined as formal and informal protocol. The former is the same as the Java interface. Methods in the Informal Protocol are design pattern considerations and do not have to be implemented, but if they are, they change the properties of the class. I actually looked at formal protocols, categories, and informal protocols a long time ago, and it’s written in the tutorial, “The concept of informal protocols is really just another way of saying categories,” here are some ways you might want to implement them, and you can use them to get things done better.” The idea is that these are optional. For example, if we want a better method, we will declare a category to implement it. Then you can directly use these better methods in the post. In this way, the category thing is kind of an alternative protocol.” Now, Protocal has already started to operate on both, because the source says that “informal protocol uses interface modifiers.” Now we see two modifiers in the protocol: “Must be implemented (@Requied)” and “Optional”.
Types that can and cannot be modified in OC.
Answer: a collection class that can be modified and cannot be modified. My personal understanding of this is that dynamically modifiable and not dynamically modifiable are the same. Like NSArray and NSMutableArray. The former memory control after initialization is fixed and immutable, the latter can be added, can dynamically apply for new memory space.
About Polymorphism
Answer: polymorphic. A pointer to a subclass can be assigned to a parent class. This topic can be applied to any object-oriented language, so it is generally best to have a self-aware understanding of polymorphism, inheritance, and encapsulation, and it is not always necessary to memorize what is written in a book. The most important thing is to translate into self-understanding.
What’s the difference between a notice and an agreement?
Answer: The protocol has a chain of control (has-a) relationship, the notification does not. First of all, I didn’t understand what the chain of control was at first. But a simple analysis of the notification and proxy behavior patterns, we can generally have their own understanding of the simple, notification, it can be one-to-many, a message can be sent to multiple message recipients. According to our understanding, the agent does not directly say that it cannot be one-to-many. For example, we know the star economic agent. In many cases, an agent is responsible for the affairs of several stars. Just for different stars, agent objects are not the same, one-to-one correspondence, it is impossible to say tomorrow to deal with A star to A news conference, agent issued after the news conference, nicknamed B’s news conference. Notifications are different. He is only interested in sending notifications, not in how many receivers he is interested in processing. Thus, the chain of control (has-a) is roughly defined by the English word, the correspondence between single ownership and control.
The difference between a thread and a process?
One application corresponds to one process, and one process helps the program occupy a chunk of storage space
In order to execute a task in a process, a thread must be opened. A thread represents a task
Multiple threads can be started in a process, that is, multiple tasks can be performed simultaneously
How does Objective-C deal with memory management? What do you think and how do you solve it?
1 Each object has a reference counter, and each new object has a counter of 1. When the object’s counter is decrement to 0, it is destroyed
Retain can change the object’s counter to +1, Release can change the object’s counter to -1
3 Memory can also be managed through the autorelease pool
If ARC is used, the compiler will automatically generate code to manage memory
What’s the difference between a heap and a stack?
1 heap space memory is dynamically allocated, generally store objects, and need to manually free the memory
2. The memory of the stack space is allocated automatically by the system, generally storing local variables, etc., without manual memory management
Why are many built-in classes such as TableView’s delegate attributes Assign instead of Retain?
1 The delegate of a TableView is usually the controller to which it belongs, and the controller will retain the view inside it
2 If the TableView retains the agent (controller) once, then there is a recurring retain problem
When defining attributes, copy, assign, retain?
1 copy: NSString, Block, etc
2 assign: Basic data types
> retain: OC object type
APP cold start optimization?
APP cold start optimization program blog is very many, the summary is roughly as follows:
Pre-main optimization: reduce dynamic and static libraries, merge dynamic libraries, remove abandoned third-party libraries and dependent system libraries, binary rearrangement (Douyin optimization scheme)
The Runtime registers the class, initializes the class object, and loads the method: simplifies the class, merges the class, removes the obsolete class, and so on
After the main function, delay the registration of the tripartite library and delay the call of the time-consuming operation function. You can locate the Time function by using the Instruments — >Time Profiler: Performance Analysis
What’s the difference between PushViewController and PresentViewController
Both are functions that jump between attempting controllers
So the PresentView Controller is providing a modal view controller
PushViewController provides an array of stack controllers, push/pop
The underlying implementation of multithreading?
1. First make clear what is thread and what is multithreading
2.Mach was the first system to handle tasks in a multithreading manner, so the underlying implementation mechanism of multithreading is based on Mach threads
3. Mach-level threads are rarely used in development, because Mach-level threads do not provide the basic characteristics of multithreading and are independent of each other
4. Implementation of multi-threading scheme in development
#include
Under what circumstances will KVO crash and how can you prevent crashes?
Crash if not used properly. For example:
Add and remove do not occur in pairs and there are cases where KVO is added by multiple threads. A common crash is when an object is removed from memory dealloc or when the Observer is not properly removed before object destruction
How to protect?
2. There is a problem with the memory wild pointer. Be sure to remove observer 3 before the object is destroyed. You can add a KVO using a third-party library, Blockkit, which automatically removes the Observer to avoid the crash.
Describe how memory is managed in iOS
Memory management in iOS is based on reference counting, which is divided into MRC(manual reference counting) and ARC(automatic reference counting). MRC: Retain and release operations are performed manually by the developer. RetainCount operations are +1 and -1 for each object. When the retainCount is 0, the system will automatically release the object memory. ARC: developers by declaring an object’s properties as strong, weak, retain, assign to manage the object reference count, be strong and retain system will automatically modify the properties of the variables of the modified variable of the increase since decreases the reference count for operation, likewise, retainCount to 0, Object memory is freed by the system.
- What is the difference between notification, proxy, block, and KVO usage scenarios? Notification: applies to the transmission of unrelated pages or system messages, belonging to the one-to-many information delivery relationship. For example, the change of system volume, the change of system state, the setting and change of application mode are all suitable for notification to convey information.
- Proxy: One-to-one transmission of information between pages that are related to each other, such as the transmission of information between pages that are pushed or presented and the original page.
- Block: The one-to-one transmission of information is more efficient than the proxy (after all, it is the direct IMP pointer operation). The applicable scenario is similar to that of proxies, which are page passes between pages that are associated with each other.
- KVO: Property listener, listens for the change of a property value of an object, used when it is needed to listen for the change of an object’s property. For example, in a UIScrollView, listening on a ContentoffSet can be done using either a KVO or a proxy. But in other cases, such as UIWebView loading progress,AVPlayer playing progress, you can only use KVO to monitor, otherwise you can not get the corresponding property value.
Those who want to receive free information can enter the skirt or add friends to get it. Here is an iOS communication circle: 710 558 675, you can come to understand, share BAT, Ali interview questions, interview experience, discuss technology, skirt information directly download, everyone exchange and learn together!
Want to interview information or other information can also find me, welcome to consult!
This is the end of the article, you can also send me a private message timely access to the interview related materials. If you have any comments and suggestions, please leave a message to me.
Please pay attention to iOS friends! If you like it, give it a like! Thank you very much! Thank you very much! Thank you very much!