I have an initial tableviewcontroller which is executing a reachability check. This is working without a problem within the viewDidLoad
, however I would like to know the correct way to Retry the connection until it passes. The pertinent code in my implementation file is below, I have tried inserting [self ViewDidLoad]
if the connection is down but this just sets the app into a loop (returning the connection failure NSLog
message) and not showing the UIAlertView
.
- (void)viewDidLoad
{
[super viewDidLoad];
if(![self connected])
{
// not connected
NSLog(@"The internet is down");
UIAlertView *connectionError = [[UIAlertView alloc] initWithTitle:@"Connection Error" message:@"There is no Internet Connection" delegate:self cancelButtonTitle:@"Retry" otherButtonTitles:nil, nil];
[connectionError show];
[self viewDidLoad];
} else
{
NSLog(@"Internet connection established");
UIButton *btn = [UIButton buttonWithType:UIButtonTypeInfoDark];
[btn addTarget:self action:@selector(infoButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
[self start];
}
}