随笔分类 - 多线程
摘要:// // ViewController.m // GCD 定时器 // // #import "ViewController.h" NSInteger count = 0; @interface ViewController () @property (nonatomic, strong)dispatch_source_t time; @end @implementation Vi...
阅读全文
摘要:1 - (void)gcdTest1 { 2 3 4 5 //1.GCD应用 单例模式 6 7 8 9 static dispatch_once_t onceToken; 10 11 dispatch_once(&onceToken, ^{ 12 13 14 15 NSLog(@"执行一次%@...
阅读全文
摘要:1.线程之间的通信 //有一个特别耗时的操作,比如说网络请求,开启子线程去请求网络,我们一般是要在主线程更新UI,如何从子线程跳转到主线程? #import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UIImageView *imageView; @end ...
阅读全文
摘要:1 1. 三种创建线程的方法 2 3 //第一种 4 5 NSThread * thread1 = [[NSThread alloc] initWithTarget:self selector:@selector(doAction) object:nil]; 6 7 //线程名 8 9 thread1.name = @"thr...
阅读全文