AFNetworking and No Internet Connection scenario

后端 未结 5 1525
误落风尘
误落风尘 2020-12-07 17:21

I use AFNetworking in my app for every request (like login, get data from url, etc).

Take this for example: an user click on the login button and there\

5条回答
  •  [愿得一人]
    2020-12-07 17:31

    Maybe you could use "Reachability" to determine if the device is connected to the network. Here is the link to the Apple Doc. : Reachability

    For example :

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNetworkChange:) name:kReachabilityChangedNotification object:nil];
    reachability = [Reachability reachabilityForInternetConnection];
    [reachability startNotifier];
    NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
    if(remoteHostStatus == NotReachable) {
      //Your UIAlertView
    }
    

提交回复
热议问题