zoukankan      html  css  js  c++  java
  • GCD

    总是习惯把知识记录在本地,是时候改变一下存储知识的方式了,丰富自己,帮助他人!

    1.GCD 的一般用法

         dispatch_async(dispatch_get_global_queue(00), ^{

       //耗时操作。。

          

            dispatch_async(dispatch_get_main_queue(), ^{        

       //通知主线程刷新

            })

    });

     

     

    2.用GCD做定时器 

    @property (nonatomic) dispatch_source_t timerSource;

    - (void)updateWithInte:(NSInteger) time{

        NSTimeInterval period = time; //设置时间间隔

        dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

        _timerSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);

        dispatch_source_set_timer(_timerSource, dispatch_walltime(NULL, 0), period * NSEC_PER_SEC, 0); //每秒执行

        dispatch_source_set_event_handler(_timerSource, ^{

            NSLog(@"nihao");

        });

        dispatch_resume(_timerSource);

    }

    作者:啡色的灰机------------------------------------------------------------------------------------------------------------ 邮箱:developer_yh@163.com--------------------------------------------------------------------------------------------- GitHub:https://github.com/developeryh
  • 相关阅读:
    Hadoop使用实例
    hdfs操作命令
    Hadoop安装与HDFS体系结构
    Linux和MySQL的安装与基本操作
    Hadoop演进与Hadoop生态
    作业一
    Shader笔记——9.简单灰色效果+遮罩
    iOS——xcodeproj脚本
    iOS——KSAdSDK
    UnityPlugins——4.SignInWithApple
  • 原文地址:https://www.cnblogs.com/devyh/p/5313506.html
Copyright © 2011-2022 走看看