I’m badly struggling with MBProgressHUD and NSURLconnection…
I’m using showWhileExecuting method to call another private method that has NSURLConnection codes inside.
-(void)HUD
{
MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Initializing";
[HUD showWhileExecuting:@selector(authenticateWithPhoneNumber) onTarget:self withObject:nil animated:YES];
}
and this is the method I’m calling via showWhileExecuting method.
-(void)authenticateWithPhoneNumber
{
// Do some stuff
// Get JSON data using NSURLConnection HERE
if(successful)
{
//EXC_BAD_ACCESS error here
[self performSegueWithIdentifier:@"A" sender:self];
}
else
{
//EXC_BAD_ACCESS error here
[self performSegueWithIdentifier:@"B" sender:self];
}
}
When I run the app, I get that EXC_BAD_ACCESS error as well as the following message:
28 0x344c0b8b
29 0x344c082b
30 0xf2d39 -[AuthenticationConfirmationViewController authenticateWithPhoneNumber]
31 0xd9013 -[MBProgressHUD launchExecution]
Assuming that those perform segue codes are the problem… I moved them to inside of the HUD method something like this…
-(void)HUD
{
MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Initializing";
[HUD showWhileExecuting:@selector(authenticateWithPhoneNumber) onTarget:self withObject:nil animated:YES];
if(successful)
{
[self performSegueWithIdentifier:@"A" sender:self];
}
else
{
[self performSegueWithIdentifier:@"B" sender:self];
}
}
Now moving to the next page is fine… EXCEPT that it jumps to one of the pages even before JSON data handling procedure is over.
What’s the problem causing all these troubles?
What’s the right way to approach to the problem in this situation?
Well original method in progress.m has to do something with threading and I am not fun of something I do not completely understand
I suggest you to use
showHUDAddedTo