I have a button on the iPhone interface that performs a function. The function is this:
-(IBAction)courses:(id)sender {
[loading startAnimating];
[connection getCourses];
[outlet setText:connection.lastResponseData];
}
My problem is that the animation only starts after the [outlet setText:connection.lastResponseData. How can I get the loading to start animating before that?
Thanks.
It looks like
getCoursesis blocking the main thread; any animations you start will be deleted until aftercourses:returns. Modify your code to use a background thread:This will put your blocking network access in a system-provided background GCD queue, which wraps a background thread.