0

I have this code in my app:

-(void)reachAlert:(Reachability*)currentReach {

    if(currentReach == hostReach) {
        //Make sure we have internet connectivity
        //UIAlertView *internetAlert = [[UIAlertView alloc] initWithTitle:@"Excellent" message:@"Host Reached" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
        //[internetAlert show];
        [[SDSyncEngine sharedEngine] startSync];


    }
    /**
     if(currentReach == internetReach) {
     //Make sure we have internet connectivity
     UIAlertView *internetAlert = [[UIAlertView alloc] initWithTitle:@"Good"
     message:@"Internet"
     delegate:self
     cancelButtonTitle:@"Cancel"
     otherButtonTitles:@"Ok", nil];
     [internetAlert show];
     }
     **/
    if(currentReach == wifiReach) {
        //Make sure we have internet connectivity
        UIAlertView *internetAlert = [[UIAlertView alloc] initWithTitle:@"Bad News"
                                                                message:@"Only wifi"
                                                               delegate:self
                                                      cancelButtonTitle:@"Cancel"
                                                      otherButtonTitles:@"Ok", nil];
        [internetAlert show];
    }
    [TestFlight passCheckpoint:@"reachAlert"];


}

As you can see I commented out internetReach because I figured, whats more important is that we have hostReach. Thus by default we must have internet reach. I also commented out the hostReach alert only because I only want to alert the user in case of NO internet connectivity.

However when testing the app on wifi, i get the bad news only wifi message. Why doesnt it give the hostReach alert?

4

2 に答える 2

1

到達可能性は、エラー メッセージの表示には理想的ではありません。理想的には、NSURLConnection が -1009 エラーを返すなど、使用しようとしている接続が失敗したときにエラー メッセージを表示する必要があります。

于 2013-07-02T23:55:50.917 に答える