AFNetworking 2.0 Reachability

后端 未结 7 1386
误落风尘
误落风尘 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:37

    As per my experience,

    [[AFNetworkReachabilityManager sharedManager] startMonitoring];
    

    takes a moment to execute setReachabilityStatusChangeBlock so there is no use returning value from -(BOOL)connected.

    So you can perform some task once network is connected/disconnected.

    The following function is best to check connectivity at the spot (synchronously):

    [AFNetworkReachabilityManager sharedManager].reachable;
    

提交回复
热议问题