记录一段神奇的代码。关键代码:
[self performSelector:@selector(recreateCommonWebView) withObject:nil afterDelay:0.1];
注释掉以后,日志执行顺序正常;否则,异步变同步。

(WKWebView *)dequeueCommonWebView
{
[self.commonSet addObject:self.preparedCommonWebView];

// 避免影响本次的加载。 5秒已经足够长了。

[self performSelector:@selector(recreateCommonWebView) withObject:nil afterDelay:0.1];

//@weakify_self;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//@strongify_self;
NSLog(@“async setup!”);
//self.preparedCommonWebView = nil;
});

NSLog(@“sync logging!”);

return nil;

// NSLog(@“current count in common = %@”, @(self.commonSet.count));
//
// if (self.preparedCommonWebView == nil)
// {
// NSLog(@“error, prepared nil!”);
// }
//
// return self.preparedCommonWebView;
}