开发者

iPhone Reachability gives a wrong network status

I used the Reachability code provided by Apple sample code. When I used cellular data network, it could detect that network. However, once I turned it off and re-run my app again, the Reachability still gave me ReachViaWMAN (NetworkStatus) similar to the cellular network. I tried reboot my iPhone with the celluar 开发者_C百科data turned off, and ran my app again. The result is the Reachability couldn't reach a host.

I'm really confused now. How to fix this problem?


The Reachability code is just sample code. There are a number of bugs in it. I remember a bug where it failed when a VPN was used for example. I know this code is used pretty much by everyone but Apple never intended it to be some sort of official API.

You are far better off understanding how the underlying APIs work and use those directly in your app. They are not difficult to use and you will catch a number of situations that Reachability does not deal with correctly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜