线程间的通信

开辟新的线程:

[NSThread detachNewThreadSelector:@selector(download) toTarget:self withObject:nil];

[self performSelectorInBackground:@selector(download) withObject:nil];

 

子线程与主线程的通信:

[self performSelectorOnMainThread:@selector(showImg:) withObject:image waitUntilDone:NO];//最后参数传NO表示不需要等待该方法执行完毕

[self performSelector:@selector(download) onThread:[NSThread mainThread] withObject:nil waitUntilDone:NO];

posted on 2019-02-16 20:27  大圣ios博客  阅读(86)  评论(0编辑  收藏  举报