AFNetworking 2.0 Reachability

后端 未结 7 1408
误落风尘
误落风尘 2020-12-07 15:33

I am trying to determine if the user is connected to the internet by using AFNetworking 2.0 and the \"AFNetworkReachabilityManager\", but it doesen\'t seem to work. It\'s al

7条回答
  •  渐次进展
    2020-12-07 16:15

    The other answers are wrong! It's better to use this to check availabilty:

    if ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
    

    The reason why is because initially networkReachabilityStatus will be set to AFNetworkReachabilityStatusUnknown until the change status block is called and this stops your code from thinking that network is unavailable when it is not.

提交回复
热议问题