I have this method:
-(IBAction)clickedDone; {
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2);
[spinner startAnimating];
//intensive stuff here
}
However, the spinner doesn’t have time (I presume) to start before the intensive stuff comes afterward which blocks the main thread I guess. I want to know if there’s a way to get this spinner animating before the thread is blocked. It’d be too much work to refactor my code to run the “intensive stuff” in a detached thread. The only alternative I can think of would be to delay the “intensive stuff” for a fraction of a second in order for the spinner to start.
What do you all think?
I think you need to put the expensive stuff on a second thread. Otherwise you block the interface as you say. It may be more work, but thats better than a bad user experience.