1

I get this error when I want to alert user if there is no internet connection

Please help me, Here is my code:

- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
    __block UIAlertView *alert = nil; 
//---------- Check Connection -------
// allocate a reachability object
Reachability* reach = [Reachability reachabilityWithHostname:@"www.google.com"];

// set the blocks
reach.unreachableBlock = ^(Reachability*reach) // not connected
{
    //NSLog(@"UNREACHABLE!");
    alert =
    [[UIAlertView alloc]
     initWithTitle: @"No Network Connection!"
     message:@"Sorry, we can't currently connect you to the app. Please check your internet connection."
     delegate:nil
     cancelButtonTitle:@"OK"
     otherButtonTitles:nil];

    [alert show];
    //[alert release];

};

reach.reachableBlock = ^(Reachability*reach)
{
    //NSLog(@"REACHABLE!");
};

// start the notifier which will cause the reachability object to retain itself!
[reach startNotifier];

}

The error is "wait_fences: failed to receive reply: 10004003" Any Suggestions?

Miss. Nada
  • 321
  • 1
  • 4
  • 14

1 Answers1

1

I got similar issue before. Because I was trying to display the alertview in a block.

I added the folowing line to my block instead of [alert show]; and everything worked fine.

[alertview performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:false];

Try to update your UI from Main Thread only, else it'll cause issues or show unpredictable results.

Midhun MP
  • 103,496
  • 31
  • 153
  • 200