You could try performing hte request like this and handle the rest from inside a block. The code inside the block will only when run when the request has returned.
So it could be something like this:
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error){
NSString *dataString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSDictionary *JSONResponse = [NSJSONSerialization JSONObjectWithData:[dataString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&error];
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
NSInteger statusCode = httpResponse.statusCode;
NSLog(@"Status: %d", statusCode);
if (JSONResponse != nil && statusCode == 200)
{
//Dismiss progress HUB here
[SVProgressHUD dismiss];
}
else
{
[SVProgressHUD dismiss];
}
}];