GCD方法,通过向主线程队列发送一个block块,使block里的方法可以在主线程中执行。
dispatch_async(dispatch_get_main_queue(), ^{
NSOperation 方法
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
NSThread 方法
[
self performSelector:@selector(method) onThread:[NSThread mainThread] withObject:nil waitUntilDone:YES modes:nil]; [self performSelectorOnMainThread:@selector(method) withObject:nil waitUntilDone:YES]; [[NSThread mainThread] performSelector:@selector(method) withObject:nil];
RunLoop方法
[[NSRunLoop mainRunLoop] performSelector:@
selector(method) withObject:nil];
转载于:https://www.cnblogs.com/yangqinglong/p/5363577.html