• 【代码笔记】iOS-GCD用法


    代码:

    复制代码
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        
        //GCD的用法
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            
            NSURL * url = [NSURL URLWithString:@"http://www.baidu.com"];
            NSError * error;
            NSString * data = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error];
            if (data != nil) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    NSLog(@"call back, the data is: %@", data);
                });
            } else {
                NSLog(@"error when download:%@", error);
            }
        });
        
        
    }
    复制代码
  • 相关阅读:
    oracle-PL/SQL1
    ROS之Gazebo
    ROS之urdf 2
    ROS之urdf 1
    ROS 面部识别
    ROS x Arduino
    STM32F0的低功耗模式
    项目进度
    C++函数返回为引用
    STM32F0的多路ADC 无DMA
  • 原文地址:https://www.cnblogs.com/yang-guang-girl/p/6697466.html
Copyright © 2020-2023  润新知