注意 ,
[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
这种方法用了默认配置,那么completeHanlder不会在mainQueue中执行,看下面的官方文档:
A queue for scheduling the delegate calls and completion handlers. If nil
, the session creates a serial operation queue for performing all delegate method calls and completion handler calls.
这样的结果就是completeHandler不在主线程执行(100%?),而是在子线程中执行。