Reputation: 3461
I am working on a script that uses Reachability
to check for an Internet connection. If there is No Internet I want it to load a second ViewController
. This is what I have so far:
-(BOOL) hasInternet {
Reachability *reach = [Reachability reachabilityWithHostName:@"http://www.google.com"];
NetworkStatus internetStatus = [reach currentReachabilityStatus];
if( internetStatus == NotReachable){
SecondViewController *second = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
[self presentViewController:second animated:YES completion:nil];
}else{
}
return YES;
}
The error I am getting is:
Attempt to present SecondViewController: 0x7ff780628d10 on ViewController: 0x7ff780719830 whose view is not in the window hierarchy!
Can anyone see where I am going wrong.
Many thanks in advance for your help and time.
Upvotes: 1
Views: 90
Reputation: 852
You are attempting to present another viewController while first ViewController has yet not loaded.
Solution:
Upvotes: 1