preface

With the continuous development and innovation of mobile Internet technology, interview is now a time-consuming and costly project for both companies, developers and designers. Questions that iOS developers and designers may encounter in the interview are screened and summarized. Let’s take a look.

How to draw UIView?

The most flexible way to draw a UIView is to draw it by itself. You’re actually not drawing a UIView, you’re subclassing a UIView and giving it the ability to draw itself.

The drawRect: method is called whenever a UIView needs to perform a drawing operation, overriding this method to give you access to the drawing operation. When the drawRect: method is called, the current graphics context is also set to belong to the view’s graphics context. You can use methods provided by Core Graphic or UIKit to draw the graphics in that context.

What is MVVM? What is the main purpose? What are the advantages?

The MVVM Model – View – namely the ViewModel

1.View is mainly used for interface presentation and interaction with user input devices.

2.ViewModel is the most important part of MVVM architecture.ViewModel contains logic such as attributes, methods, events, and attribute verification, which is responsible for the communication between View and Model

3.Model is often referred to as data Model, which is used for data construction and data driving, and mainly provides the attributes of the underlying entities.

The main purpose of MVVM is to separate the view from the model

MVVM benefits: low coupling, reusability, independent development, testable

Get request and POST request

1. Get is a request for data sent to the server, and POST is a request for data submitted to the server

2. Get does not have a request body, but POST does

3. The data of a GET request is exposed in the address bar, but that of a POST request is not. Therefore, the security of a POST request is higher than that of a GET request number

4. A GET request has a limit on the URL length, while a POST request has no limit on the URL length. However, in practice, each server has a limit on the size of the DATA submitted by POST.

What is your understanding of multi-threaded development? How many ways are there to implement multithreading in ios?

Benefits:

1. The use of multithreading can take a long time in the program to the background to deal with tasks, such as pictures, video download;

2. Give full play to the advantages of multi-core processor and concurrent execution to make the system run faster, more smoothly and better user experience;

Disadvantages:

1. Large numbers of threads reduce code readability;

2. More threads require more memory;

When multiple threads compete for the same resource, attention should be paid to thread safety.

There are 3 kinds of multithreaded programming techniques in ios: 1.NSThread, 2.NSOperationQueue, 3.

5. XMPP working principle; XMPP system features

Principle:

1. All jabber messages and data sent from one client to another pass through the XMPP server

2. The client connects to the server

3. The server uses the certificate of the local directory system to authenticate it

4. The server searches, connects, and authenticates each other

5. Clients interact with each other

Features: 1) Client/server communication mode; 2) Distributed network; 3) Simple client; 4) DATA format of XML

Six, map positioning is how to achieve?

1. Corelocation. framework is imported

2. After ios8, if you need to use the location function, you need to request user authorization, and a pop-up message is displayed when you run it for the first time

3. Obtain position information (latitude and longitude) through the GPS of the machine

Vii. Realization process of Apple internal purchase

The program gets a list of product identifiers from the plist file stored in the bundle.

The application sends a request to the App Store to get information about the product.

The App Store returns product information.

The App displays the returned product information to the user (App Store interface)

The user selects a product

The application sends a payment request to the App Store

The App Store processes payment requests and returns transaction completion information.

The App takes the information and provides the content to the user.

Viii. Integration of SDK of Alipay, wechat and other related types

1. Create an application on the Alipay development platform and obtain the APPID

2. Configure the key

3. Integrate and configure the SDK

4. Call interface (such as transaction query interface, transaction refund interface)

GCD deadlock causes and unlock methods

The necessary conditions for deadlock are: 1. Mutual exclusion condition, 2. Request and hold condition, 3. Loop wait conditions.

Workaround: Execute blocks asynchronously.

Ten, the generation of two-dimensional code steps

1. Use CIFilter to generate the QR code

2. Process the generated TWO-DIMENSIONAL code to make it clearer

3. Customize the background color and fill color of two-dimensional code

4. Customize positioning markers

5. Insert a small picture in the center of the QR code

Are there any difficulties in using XMPP

Send attachments (pictures, voice, documents…) Time is more troublesome

The XMPP framework does not provide the ability to send attachments, so you need to implement it yourself

To achieve this, upload the file to the file server, obtain the file saving path after uploading successfully, and then send the attachment path to friends

Twelve, whether to use the ring letter, simply say the realization principle of the ring letter

Huanxin is an instant messaging service provider

Ring letter uses XMPP protocol, which is developed on the basis of XMPP. It adds functional models of server Openfire and client and encapsulates client SDK. In essence, ring letter still uses XMPP and network communication based on Socket

Huanxin internal implementation of data caching, chat records will be added to the database, the attachment (such as audio files, pictures) download to the local, so that programmers spend more time on user experience.

That’s the end of this article, and I hope it’s helpful for iOS developers in their interviews. If you have any questions, please leave a comment.