主线程到子线程的相互切换
很简单的两个方法
[self performSelectorInBackground:<#(SEL)#>
withObject:<#(id)#>];
[self performSelectorOnMainThread:<#(SEL)#>
withObject:<#(id)#>
waitUntilDone:<#(BOOL)#>];
withObject:<#(id)#>];
[self performSelectorOnMainThread:<#(SEL)#>
withObject:<#(id)#>
waitUntilDone:<#(BOOL)#>];
主现在发现子线程切到主线程还可以用:
dispatch_async(dispatch_get_main_queue(), ^{
//your code
});
//your code
});