I have a method say someMethod(), I always want this method should be executed under main thread. So I wrote this method like this..
-(void)someMethod
{
if([NSThread mainThread])
{
// Do method stuffs
}
else
{
[self performSelectorOnMainThread:@selector(someMethod) withObject:nil waitUntilDone:YES];
}
}
Questions:
- Is it the right approach?
- If, I call this method by background thread, what will happen?
Thanks