Hi all,
I have an app that performs some calculations based on data arriving on a socket or local user interaction.
I want to show an 'activity spinner' whilst the calculation happens.
spinner = [[UIActivityIndiactorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[spinner setCenter:self.view.center];
[self.view addSubview:spinner];
[spinner startAnimating];
[self performSelector:@selector(doCalcs) withObject:nil afterDelay:0];
This works well, except in the case where the code is run as a result of a message arriving over the network. I'm using http://code.google.com/p/cocoaasyncsocket/ to handle sockets and the code is running in the onSocket:didReadData:withTag: method.
'doCalcs' takes a few seconds. The spinner doesn't appear whilst it's running.
If I change afterDelay:0 to afterDelay:1 then the spinner does appear the whole time doCalcs is running, but with the downside that it takes an extra second. So it seems the code is all correct, but for whatever reason the spinner isn't getting a chance to get on screen before doCalcs runs.
Any suggestions would be most welcome.