Summary of 12 iOS technical interview questions and answers

  • 2021-01-14 06:45:46
  • OfStack

preface

With the continuous development and innovation of mobile Internet technology, interview is a time-consuming and costly project for companies, developers or designers nowadays. In this paper, problems that iOS developers and designers may encounter during interview are screened and summarized. So let's do it one by one.

1. How to draw UIView?

Draw a UIView The most flexible method is to let it do the drawing itself. You don't actually draw 1 UIView , instead of subclassing 1 UIView And give them the ability to draw their own. When a UIView When you need to perform a draw operation, drawRect The: method is called, and overriding this method gives you a chance to draw. when drawRect The: method is called, and the context of the current graphic is set to the graphic context of the view. You can draw the graphic in this context using methods provided by Core, Graphic or UIKit.

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

MVVM Model - View - namely ViewModel

1. View Mainly used for interface presentation, interaction with user input devices,

2. ViewModel Is the most important part of the MVVM architecture. ViewModel Contains logic such as attributes, methods, events, and attribute validation View with UIView0 Communication between

3. UIView0 It's what we call a data model, which is used to construct data, to drive data, and to provide the properties of the underlying entities.

The main purpose of MVVM is to separate views and models

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

3. Differences between get requests and post requests

1. get Is a request to a server for data, and post A request to submit data to the server

2. get There is no request body, post Has a request body

3. get The requested data is exposed in the address bar, and post Requests don't, so post Request is more secure than get request number

4. get Request a limit on url length, and post There is theoretically no limit on the ES87en length of requests, but in practice individual servers do post Submit data size limits.

4. What is your understanding of multithreaded development? How many ways are there to implement multithreading in ios?

Benefits:

1. Using multi-threading can put tasks which occupy a long time in the program into the background to deal with, such as downloading pictures and videos;

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

Disadvantages:

1. A large number of threads reduces the readability of the code;

2. More threads require more memory space;

3. When multiple threads compete for the same resource, we should pay attention to the problem of thread safety.

ios has three multithreaded programming techniques: 1.NSThread, 2.NSOperationQueue, 3.gcd;

5. Operating principle of XMPP; xmpp system features

Principle:

1. All from 1 client To the other one client the jabber Messages and data go through xmpp server

2. client Link to server

3. server Authenticate it with a certificate from the local directory system

4. server Find, connect, and authenticate each other

5. client To interact with each other.

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

6. How is the location of the map realized?

1. Import CoreLocation.framework

2. After ios8, if you need to use the location function, you need to request the user authorization, and it will be prompted by the pop-up box during the first run

3. Obtain location information (i.e., latitude and longitude) through gps on the machine

7. Apple In-App Purchase implementation process

Program by bundle Storage of UIView0 The file gets a list of product identifiers.

The program sends a request to App Store for information about the product.

App Store returns product information.

The program displays the returned product information to the user (store interface of App)

The user selects a product

The program sends a payment request to App Store

App processes the payment request and returns the transaction completion information.

App gets the information and provides the content to the user.

8. sdk integration of Alipay, WeChat and other related types

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

2. Configure the key

3. Integrate and configure SDK

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

9.gcd Deadlock Causes and Unlocking Methods

Necessary conditions for deadlock: 1. mutex condition, 2. request and hold condition, 3. no deprivation condition, 4. Loop wait conditions.

Solution: asynchronously execute block.

10. Steps to generate 2D codes

1. Use UIView1 The filter class generates 2-dimensional codes

2. Process the generated 2-D codes to make them clearer

3. Customize the 2D code background color and fill color

4. Custom positioning corner marker

5. Insert a small picture in the center of the 2-D code

101. Are there any difficulties in using XMPP

Send attachment (picture, voice, document...) It's a little bit troublesome when

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

The implementation method is to upload the file to the file server, obtain the file saving path after uploading successfully, and then send the attachment path to a friend

102. Have you ever used ring letter? Let me briefly explain the principle of ring letter

Global message is an instant messaging service provider

Ring letter using XMPP protocol, it is on the basis of XMPP for two times to develop the server Openfire and client function model to add and client SDK encapsulation, ring letter is the essence of using XMPP, network communication based on Socket

Huan letter internal implementation of data cache, will add the chat record to the database, the attachment (such as audio files, picture files) to the local download, so that programmers spend more time on the user experience.

conclusion
That's the end of this article. I hope this article will be helpful to you iOS developers during the interview. If you have any questions, please feel free to leave a comment.


Related articles: