iOS Interview Notes (3)

The advantages and disadvantages of arrays and linked lists

1. Array is a continuous space in memory, that is, it is stored sequentially, so it is more efficient to query data through indexes ; while for array insertion and deletion operations, the efficiency will be relatively low, insert data in the first position. , the rest of the data needs to be moved backward in sequence, and the deletion of the first data requires all data to be moved forward.

2. The storage consists of two parts, data and pointers. The storage in memory is discontinuous. The linked list is composed of a series of nodes, each node will have a link point, which is the next chain, and the next chain will execute the reference of the next node, so when we insert or delete, we need the next chain of the list linked list It is enough to point to the address, each node does not need memory for continuous storage, which will reduce the linear overhead of deletion and insertion. The linked list structure is mainly divided into two linked lists, singly linked list and doubly linked list, that is, a singly linked list has only one next chain, while a doubly linked list has a next chain and a pre chain.


2. iOS catch exception and get crash log

1. Add an exception capture listener when the program starts to handle the callback action when the program crashes

NSSetUncaughtExceptionHandler(&UncaughtExceptionHandler);
UncaughtExceptionHandler is a function pointer, this function needs to be implemented by us, and we can take the name we want. This function is called when the program crashes abnormally.
2. Implement the processing function
void UncaughtExceptionHandler(NSException *exception) {
    NSArray *arr = [exception callStackSymbols];//Get the current call stack information
    NSString *reason = [exception reason];//Very important, that is the reason for the crash
    NSString *name = [exception name];//Exception type
   
}
3. There are two main ways to send it to developers
a. Persist the crash information locally, and send the crash information as a log to the developer the next time the program starts.
b. Send it to the developer by email. However, this method requires the user's permission, because iOS cannot send text messages or emails in the background, and an interface for sending emails will pop up, which can only be sent when the user clicks Send.
NSString *crashLogInfo = [NSString stringWithFormat:@"exception type : %@ \n crash reason : %@ \n call stack info : %@", name, reason, arr];
    NSString *urlStr = [NSString stringWithFormat:@"mailto://[email protected]?subject=bug report&body=Thanks for your cooperation!
Error details: %@",crashLogInfo];
    NSURL *url = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    [[UIApplication sharedApplication] openURL:url];

3. Custom Camera
Customize the camera using the system library AVFoundation to get the iOS custom camera in 30 minutes


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325388711&siteId=291194637