Your problem is that block your main thread using the sendSynchronousRequest.
While the data is downloading your thread is blocking and so your animation too, and after the request has been done the animation continue.
I should you to use the connectionWithRequest:delegate: or the initWithRequest:delegate: methods and set the delegate to self.
You can find more information here: Using NSURLConnection
EDIT:
Example:
In your interface define it:
@interface YourInterface {
@private
NSMutableData *receivedData;
}
then in your controller into the viewDidLoad:
// your previous definition of your NSMutableRequest
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if (theConnection) {
// Create the NSMutableData that will hold
// the received data
// receivedData is declared as a method instance elsewhere
receivedData=[[NSMutableData data] retain];
} else {
// inform the user that the download could not be made
}
to finish, again in you controller, implement these methods:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
// append the new data to the receivedData
// receivedData is declared as a method instance elsewhere
[receivedData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
// release the connection, and the data object
[connection release];
// receivedData is declared as a method instance elsewhere
[receivedData release];
// inform the user
NSLog(@"Connection failed! Error - %@ %@",
[error localizedDescription],
[[error userInfo] objectForKey:NSErrorFailingURLStringKey]);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
// do something with the data
// receivedData is declared as a method instance elsewhere
NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]);
// release the connection, and the data object
[connection release];
[receivedData release];
}