0

I am doing this in my app :

-

 (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.i
    NSURL *url = [NSURL URLWithString:@"http://www.mySite.fr"];

    NSURLRequest *request = [NSURLRequest requestWithURL:url];

    [self.myWebView loadRequest:request];
    self.myWebView.scalesPageToFit = YES;
}

When i have not the network ( no connexion) nothing is shown ( just a white page witch is the web view).

My question is should i put an alert to the user when there is no network ? how i ca do this ? thanks ? will my app rejected if i don't show an alert to the user ?

Thanks for your answers

samir
  • 19
  • 2

2 Answers2

1

I do not think that not checking for a connection will cause your app to be rejected, but you should do it anyway.

Ed Marty has pointed out that my original suggestion of using

- (BOOL)checkResourceIsReachableAndReturnError:(NSError **)error

will not work in iOS (thanks!).

This StackOverflow question appears to have a working solution to the problem.

Community
  • 1
  • 1
Katfish
  • 698
  • 7
  • 13
  • 1
    Take a closer look at that method's discussion. Specifically, where it says "This method is unimplemented in iOS, so it performs no operation." Unfortunately you'll need to use something like the Reachability example provided with the iOS API reference, which is much more cumbersome. – Ed Marty Jun 21 '11 at 01:59
1

While it makes sense to check for reachability, I think you have a better approach using the delegate method webView:didFailLoadWithError: which will tell you if the web view has failed to load your page. In such a case, rather than popping an alert view load some kind of local HTML page indicating that the load has failed if you wish and set a timer to trigger a reload after a while.

As such I don't think Apple will reject you for this unless it is the only thing the App does. But you will have to give a thought on the user experience when the load fails.

Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105