I do a post request using Async
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
I have the call backs for when the connection has stopped and in here I call my method for stopping the UIActivityIndicatorView
-(void)connectionDidFinishLoading:(NSURLConnection*)connection
{
NSLog(@"Connection finish");
[self stopAnimatingSpinner];
}
Heres the stop animating method (I have tried a combination and all of the below stop, remove hide methods
-(void)stopAnimatingSpinner{
[submittingActivity stopAnimating];
submittingActivity.hidden = YES;
[submittingActivity removeFromSuperview];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}
Now the problem is sometimes it stops sometimes it doesnt and is very random. If I move the stopping of the activity to the finish parsing of my data instead of relying on the connection callbacks the behaviour is exactly the same. Sometimes they stop sometimes they don't?
The only thing I can think of is that the connection is blocking the main thread but why would it work sometimes and not others?