Preface
With the continuous development and innovation of mobile Internet technology, interviews are now a time-consuming and cost-effective project for both companies, developers and designers, and the problems that iOS developers and designers may encounter during interviews have been screened and summarized. Let’s take a look together below.
1. How to draw a UIView?
Draw aUIView
The most flexible way is to draw it yourself. You're not actually drawing oneUIView
, instead subclassing oneUIView
And empower yourself to draw. When aUIView
When drawing operations are required,drawRect
: The method will be called, overwriting this method gives you the opportunity to draw operations. whendrawRect
: The method is called, and the context of the current graph is also set to the graphical context of the view. You can use the methods provided by Core Graphic or UIKit to draw the graph in this context.
2. What is MVVM? What is the main purpose? What are the advantages?
MVVM is Model-View-ViewModel
1.View
Mainly used for interface presentation, interacting with user input devices,
2.ViewModel
It is the most important part of the MVVM architecture.ViewModel
It contains properties, methods, events, attribute verification and other logic, and is responsible forView
andModel
Communication between
3.Model
It is what we often call a data model, used for data construction and data driving, and mainly provides the properties of the basic entity.
The main purpose of MVVM is to separate views and models
Advantages of MVVM: low coupling, reusability, independent development, testable
3. The difference between get request and post request
1.get
It is a request to request data from the server, andpost
It is a request to submit data to the server
2.get
No request body,post
There is a request
3.get
The requested data will be exposed to the address bar, andpost
The request won't, sopost
The security of the request is greater than the get request number
4.get
The request has a limit on the length of the url, andpost
In theory, there will be no restrictions on the url length, but in fact, each server will specify thepost
Submit data size to limit.
4. Tell me about your understanding of multi-threaded development? How many ways to implement multithreading in ios?
benefit:
1. Using multithreading, you can put tasks that take up a long time in the program in the background to process, such as downloading pictures and videos;
2. Give full play to the advantages of multi-core processors, and concurrent execution makes the system run faster, smoother and better user experience;
shortcoming:
1. A large number of threads reduce the readability of the code;
2. More threads require more memory space;
3 When multiple threads compete for the same resource, pay attention to thread safety issues.
iOS has 3 multi-threaded programming techniques:,,;
5. XMPP working principle; xmpp system features
principle:
1. All from oneclient
Go to anotherclient
ofjabber
Both messages and data must be passed through xmpp server
2.client
Link to server
3.server
Authenticate it with the certificate of the local directory system
4.server
Find, connect and authenticate each other
5.client
Interact between
Features:1) Client/server communication mode; 2) Distributed network; 3) Simple client; 4) XML data format
6. How is the positioning of the map implemented?
1. Imported
2. After ios8, if you need to use the positioning function, you need to request user authorization. A box will pop up when running it for the first time.
3. Obtain location information (i.e. latitude and longitude) through the native GPS
7. Apple’s in-app purchase process
The program passesbundle
Storedplist
The file gets a list of product identifiers.
The program sends a request to the App Store to get product information.
The App Store returns product information.
The program displays the returned product information to the user (App store interface)
Users select a product
The program sends payment request to the App Store
The App Store processes payment requests and returns transaction completion information.
The app obtains information and provides content to users.
8. Integration of related types of SDKs such as Alipay, WeChat, etc.
1. Create an application on the Alipay development platform and obtain the APPID
2. Configure the key
3. Integrate and configure SDK
4. Call the interface (such as transaction query interface, transaction refund interface)
9. The reasons for deadlocks and methods for unlocking gcd
Necessary conditions for generating deadlock: 1. Mutual Exclusive conditions, 2. Request and Hold conditions, 3. Non-deprived conditions, 4. Loop waiting conditions.
Solution:Use asynchronous execution of blocks.
10. Steps to generate a QR code
1. UseCIFilter
Filters generate QR codes
2. Process the generated QR code to make it clearer
3. Customize the QR code background color and fill color
4. Custom positioning angle mark
5. Insert a small picture in the center of the QR code
11. Are there any difficulties when using XMPP
Sending attachments (pictures, voice, documents...) is more troublesome
The XMPP framework does not provide the function of sending attachments, and needs to be implemented by itself.
Implementation method: upload the file to the file server, obtain the file saving path after the upload is successful, and then send the attachment path to a friend
12. Whether you have used the Ringxin, simply talk about the implementation principle of Ringxin
Huanxin is an instant messaging service provider
Huanxin uses the XMPP protocol, which is secondary development based on XMPP, adding functional models to the server Openfire and client and encapsulating the client SDK. The essence of Huanxin is still to use XMPP and Socket-based network communication.
Huanxin implements data caching internally, which will add chat records to the database and download attachments (such as audio files and picture files) locally, so that programmers spend more time on user experience.
Summarize
The above is the entire content of this article. I hope the content of this article will be helpful to all iOS developers during the interview. If you have any questions, you can leave a message to communicate.