performSelectorInBackground: on main thread
I 开发者_C百科know this is a wack question, but it is valid to performSelectorInBackground: on an iPhone apps' main thread? I am aware of performSelectorOnMainThread: but I was just wondering if performSelectorInBackground: can also be used on the main thread. My understanding is it cannot, because performSelectorInBackground: spawns a new thread each time.
performSelectorInBackground:
essentially spawns a new thread, then performs the desired selector on that thread.
So, no it does not execute on the main thread. Ever.
I think that using performSelector:withObject:afterDelay:
without a delay would be appropriate for your situation, because that does perform the selector on the main thread, except that it's performed in the next iteration of the current run loop:
[self performSelector:@selector(someMethod) withObject:nil afterDelay:0];
精彩评论