将一个行数在主线程执行的4中方法

 1-GCDblockblock

dispatch_async(dispatch_get_main_queue(), ^{

});

2-NSOperation

NSOperationQueue *mainQueue = [NSOperationQueue

mainQueue];

NSBlockOperation *operation = [NSBlockOperation

blockOperationWithBlock:^{

}];

[mainQueue addOperation:operation];

3-NSThread

[selfperformSelector:@selector(method)

onThread:[NSThread mainThread] withObject:nilwaitUntilDone:YESmodes:nil];

[selfperformSelectorOnMainThread:@selector(method)

withObject:nilwaitUntilDone:YES];

[[NSThread mainThread] performSelector:

@selector(method) withObject:nil];

4-RunLoop

[selfperformSelectorOnMainThread:@selector(method)

withObject:nilwaitUntilDone:YES];

[[NSThread mainThread] performSelector:

@selector(method) withObject:nil];

• RunLoop

[[NSRunLoop mainRunLoop] performSelector:@selector(method) withObject:nil];

posted @ 2016-11-16 23:58  华少不思议  阅读(140)  评论(0编辑  收藏  举报