简体   繁体   English

可以检查我的主机的当前状态并且无需使用通知中心

[英]Reachability to check the current status of my Host and No Need to use Notification Center

I am using Reachability Code to check the network status of ip but currently i am using NSNotification Center. 我正在使用可达性代码来检查ip的网络状态,但是当前我正在使用NSNotification Center。 But i don't want to check like that. 但是我不想这样检查。 I need to check the network status only when i try to download something from my host. 仅当我尝试从主机下载某些内容时,才需要检查网络状态。

Currently the internet connection is able to check properly but not able to check host reachability. 当前,Internet连接能够正确检查,但不能检查主机的可达性。 How to do this? 这个怎么做?

Reachability Guide for iOS 4 iOS 4可达性指南

reachability should be added whereever ur going to access the network.otherwise apple may reject ur app.if u want to test particularly ur host then use call back connection failed with error callback to display some alertview with error or make ur own message. 无论您要访问网络的何处,都应添加可达性。否则,苹果可能会拒绝您的应用程序。如果您要特别测试您的主机,请使用回调连接失败并返回错误回调来显示一些带有错误的Alertview或发送自己的消息。

How about something like this: 这样的事情怎么样:

  1. Use Reachability to see if connectivity is available 使用可达性查看连接是否可用
  2. Try to download a file from your site if there is a network 如果存在网络,请尝试从您的站点下载文件
  3. If you can't download the file, you'll get an error - deal with it gracefully. 如果您无法下载文件,则会收到错误消息-请妥善处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM