//开启多线程一直扫描 当前wifi是否和扫描到的wifi相同
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(isGoWebView:) userInfo:nil repeats:YES];
// do {
// [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
// } while (isCurrentWifiNameEqualToScanWifiName == NO); //当前wifi与扫码扫到的wifi不相同时
while (isCurrentWifiNameEqualToScanWifiName == NO) {
// [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
// [runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:10.0]]; //每隔10秒检查下线程循环条件
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:1.0f]];
}
if (isCurrentWifiNameEqualToScanWifiName == YES) {
dispatch_async(dispatch_get_main_queue(), ^{
WebViewController *wVC = [[WebViewController alloc] init];
[self.navigationController pushViewController:wVC animated:YES];
[wVC loadDataWithUrlStr:_regularString];
});
}
});
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSTimer *timer = [NSTimer timerWithTimeInterval:1.0f target:self selector:@selector(isGoWebView:) userInfo:nil repeats:YES];
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
[runLoop addTimer:timer forMode:NSDefaultRunLoopMode];
while (isCurrentWifiNameEqualToScanWifiName == NO) {
[runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0f]];
}
if (isCurrentWifiNameEqualToScanWifiName == YES) {
dispatch_async(dispatch_get_main_queue(), ^{
WebViewController *wVC = [[WebViewController alloc] init];
[self.navigationController pushViewController:wVC animated:YES];
[wVC loadDataWithUrlStr:_regularString];
});
}
});