Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wait_fences: failed to receive reply: 10004003 error - UIAlert WITHOUT UITextField present

I am working on an app where a UIAlert pops up the first time the user begins using it to ask if they want to use their current location. This happens within the main controller. However, I get the following error when using the UIAlert:

wait_fences: failed to receive reply: 10004003

I debugged it, and googled around. I am not using a textarea or keyboard input, so I don't have to resign a first responder. However, I still cannot figure out why I would be getting this error. It only appears when I add the UIAlert.

MainController.m

- (void)viewDidLoad {

    UIAlertView *mainAlert = [[UIAlertView alloc]
                      initWithTitle:@"Location" 
                      message:@"Do you wish to use your current location?" 
                      delegate:self 
                      cancelButtonTitle:nil 
                      otherButtonTitles:@"No Thanks", @"Sure!", nil];

    [mainAlert show];
    [mainAlert release];

    [super viewDidLoad];
}

The header file is constructed like this:

@interface MainController : UIViewController 
<CLLocationManagerDelegate,
 MKReverseGeocoderDelegate, UIAlertViewDelegate>
like image 517
squeezemylime Avatar asked Nov 22 '10 02:11

squeezemylime


3 Answers

The reason for this wait_fences: failed to receive reply: can also be that you try to show an alert while not being on the mainThread (which is the GUI thread).

Dispatching to the GUI thread helps:

dispatch_async(dispatch_get_main_queue(), ^{ 
  [mainAlert show];
});
like image 71
MacMark Avatar answered Nov 15 '22 20:11

MacMark


I solved this problem by adding a slight delay to the UIAlert: The below is within my ViewDidLoad method (it also works fine within ViewDidAppear):

[self performSelector:@selector(testAlert) withObject:nil afterDelay:0.1];

for some reason that delay did the trick. I then called another method (I will rename it of course..):

- (void) testAlert
{
    UIAlertView *mainAlert = [[UIAlertView alloc] initWithTitle:@"Location" message:@"Do you wish to use your current location?" delegate:self cancelButtonTitle:nil otherButtonTitles:@"No Thanks", @"Sure!", nil];

    [mainAlert show];
    [mainAlert release];
}
like image 37
squeezemylime Avatar answered Nov 15 '22 21:11

squeezemylime


Always call [super viewDidLoad]; before you do anything else. That is also explaining why the delay works.

Hope I'm right. :)

like image 40
Glünggi Avatar answered Nov 15 '22 20:11

Glünggi