IOS interview questions

Source: Internet
Author: User

I have summarized some interview questions to share with you the continuous updates...

MVC Mode

The MVC design pattern considers three objects: model object, view object, and controller object. Model objects have special knowledge and professional skills on behalf of tables. They are responsible for retaining application data and defining the logic of operation data. View objects know how to display the model data of an application and may allow users to edit it. The Controller object is the coordinator between the view object and model object of the application.

What are the differences between threads and processes?

Processes and threads are the basic units for running programs that the operating system understands. The system uses this basic unit to implement the system's concurrency for applications. The main difference between processes and threads is that they are different operating system resource management methods. A process has an independent address space. After a process crashes, it will not affect other processes in the protection mode, but the thread is only a different execution path in the process. A thread has its own stack and local variables, but there is no separate address space between threads. When a thread dies, the whole process dies. Therefore, multi-process programs are more robust than multi-threaded programs, however, during process switching, resources are consumed and the efficiency is lower. But for some concurrent operations that require simultaneous and shared variables, you can only use threads, not processes.

Functions of readwrite, readonly, assign, retain, copy, and nonatomic attributes

@ Property is an attribute access statement. The extension number supports the following attributes:

1, getter = getterName, setter = setterName, set the method names of setter and getter

2, readwrite, readonly, set the available access level

2. The assign and setter Methods assign values directly without any retain operations. To solve the original type and cycle reference problems

3. The retain and setter Methods perform the release old value for the parameter and retain the new value. All implementations are in this Order (relevant information is available on CC)

4. copy and setter Methods perform the Copy operation. Like the retain process, the old value is release first, and then the new object is copied. retainCount is 1. This is a mechanism introduced to reduce context dependencies.

5. nonatomic: Non-atomic access without synchronization. multi-thread concurrent access improves performance. Note: If this attribute is not added, both access methods are atomic transaction access by default. The lock is added to the object instance level (I understand this ...). @ Synthesize xxx; To implement the actual code

7. Does obj-c have multi-inheritance? Is there any alternative?

All classes in cocoa are NSObject sub-classes that inherit from each other. Here, we use protocol to delegate agents to implement the ood polymorphism in obj-c through delegation.

1. In ObjC, is the method opposite to alloc semantics dealloc or release? The method opposite to the retain syntax is dealloc or release. Why? The method to be paired with alloc is dealloc or release. Why?

A: The opposite is true for alloc and dealloc. alloc is the creation variable, and dealloc is the release variable. Retain corresponds to release, and retain retains an object. After the call, the variable count is increased by 1.

Why do many built-in classes such as the delegate attribute of UITableViewController use assign instead of retain?

A: This will cause loop reference.

What is Category? What are the advantages and disadvantages?

Category: the advantage of adding a new method to an existing class is that you can add a new method to this class without knowing the source code. The disadvantage is that this method may be overwritten, but I don't know it.

Advantages of MVC

◆ Low coupling. The view layer and business layer are separated so that you can modify the view layer code without re-compiling the model and controller code. Similarly, to change the business flow or rules of an application, you only need to change the MVC model layer. Because the model is separated from the Controller and the view, it is easy to change the data layer and business rules of the application.

◆ High reusability and applicability.

◆ Low life cycle costs. MVC makes it possible to reduce the technical content of user product development and maintenance.

◆ Fast deployment. Using the MVC mode, the development time is greatly reduced. It enables programmers (Java developers) to concentrate on business logic and interface programmers (HTML and JSP developers) centralized Business in the form of performance.

◆ Maintainability. The view layer and business logic layer make WEB applications easier to maintain and modify.

◆ Conducive to software engineering management.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.