IOS Interview Questions:

IOS Interview Collection + Answer (1)

IOS Interview Collection + Answer (2)

IOS Interview Collection + Answer (3)

IOS Interview Collection + Answer (4)

IOS Interview Collection + Answers (5)

Common iOS Development Interview Questions

A learning route for iOS developers

Using GCD to handle multithreading, under the multi-core CPU, will improve the efficiency of execution, the following is a GCD code used in the project.

1. - (void)gcdDownload 2. { 3. static dispatch_once_t once; 4. static dispatch_queue_t queue; 5. //create download queue 6. dispatch_once(&once, ^{ 7. queue =dispatch_queue_create("com.xxx.download.background",DISPATCH_QUEUE_CONCURRENT); 8.}); 9. //__block type 10. __block BOOL downloadFlag = NO; 11. dispatch_async(queue, ^{ 12. // downloadFlag = [Download sendRequest:request]; 13. NSLog(@" long time task, such as network download "); 14.}); 15.16. Dispatch_barrier_async (queue,^{17. if (downloadFlag) {18.nslog (@" Download completed successfully "); 19.} 20.21. Dispatch_async (dispatch_get_main_queue(), ^{22.nslog (@" after the download, drop back to the main thread, e.g. refresh UI"); 23. 24.}); 25.}); 26.}Copy the code

You can put multiple concurrent blocks in a queue.

The original: blog.csdn.net/xunyn/artic…