zoukankan      html  css  js  c++  java
  • 线程间通信

      //创建url
        NSURL *url = [NSURL URLWithString:str];
        //创建请求
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
        //发送请求
    //    NSOperationQueue *queue = [NSOperationQueue mainQueue];
        NSOperationQueue *queue = [[NSOperationQueue alloc] init];
        [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
            NSLog(@"%@",[NSThread currentThread]);
            //JSON解析
            NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
            if (dict[@"success"]) {
                //回到主线程显示
                dispatch_async(dispatch_get_main_queue(), ^{
                     [MBProgressHUD showError:dict[@"success"]];
                });
             
            }else
            {
                // NSOperationQueue *queue = [[NSOperationQueue alloc] init];如果来到这,会卡死在子线程
                [MBProgressHUD showError:@"!"];
            }

            

  • 相关阅读:
    PBN飞越转弯Flyover衔接DF航段保护区组图
    子群
    点集拓扑
    近世代数总结
    windows目标进程注入dll
    api文档方法参数
    windows制作动态链接库和使用二
    windows制作动态链接库和使用一
    拷贝构造函数
    c++内联函数
  • 原文地址:https://www.cnblogs.com/hl-iOS/p/4834008.html
Copyright © 2011-2022 走看看