IOS6学习笔记(四)

1.GCD设置一个timer计时器

- (void)awakeFromNib {

    __weak id weakSelf = self;

    double delayInSeconds = 0.25;

    _timerdispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,dispatch_get_main_queue());

    dispatch_source_set_timer(_timer, dispatch_walltime(NULL, 0),(unsigned)(delayInSeconds * NSEC_PER_SEC), 0);

    dispatch_source_set_event_handler(_timer, ^{

        [weakSelf updateValues];

    });

    dispatch_resume(_timer);

}

- (void)updateValues {

}

- (void)dealloc {

    dispatch_source_cancel(_timer);

}

你可能感兴趣的:(学习笔记)