Simple question: what happens if I do this:
- (void)viewDidLoad
{
[self performSelectorInBackground:@selector(myBGMethod) withObject:nil];
}
-(void)myBGMethod
{
[self myOtherMethod];
}
-(void)myOtherMethod
{
NSLog(@"This is not Inception");
//some more code here
}
Will the NSLog() and other code in myOtherMethod be run on the main thread or in the background?
It’ll be run in the background thread.
You can confirm this by calling
NSLoginside all your methods. By default,NSLogprints the thread number along the process ID (pid).