I. Asynchronously loading a network picture
1. ATS(1) Introduction
Starting with iOS9.0, if you write the code in the previous way, the following warning message is reported when accessing the network:
APP Transport Security has blocked a cleartext HTTP (/HTTP) resource load since it is insecure.
Temporary exceptions can be configured via your app ' s info.plist file.
Reason: iOS9.0 introduced a new feature (app Transport Security), referred to as ATS, and applied transport safety.
The new feature requires that the network access within the app must use the HTTPS protocol.
(2) Solutions
Method One:
1> add nsapptransportsecurity type in Info.plist Dictionary
2> Add nsallowsarbitraryloads type Boolean under Nsapptransportsecurity, set to YES
Method Two:
Add in Info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Method Three:
code block
2. Write code
(1) First step: defining attributes
(2) Step two: Initialize the control
(3) Step three: Download images (download images asynchronously)
3. Communication between threads
(1) What is called inter-thread communication?
In a process, threads often do not exist in isolation, and there is a need for frequent communication between multiple threads.
The small secret buys the smoke, must have to return to the Monitor report.
(2) The embodiment of inter-thread communication
1 Threads passing data to another thread
After performing a specific task in one thread, go to another thread to continue the task
(3) Common methods of inter-thread communication
-(void) Performselectoronmainthread: (SEL) Aselector Withobject: (nullable ID) arg waituntildone: (BOOL) wait;
-(void) Performselector: (SEL) aselector onthread: (Nsthread *) THR Withobject: (nullable ID) arg waituntildone: (BOOL) wait ;
iOS developing multi-threaded article--Loading network pictures asynchronously