iPhone、NSData、wifi 与蜂窝网络

发布于 2024-10-01 06:49:31 字数 316 浏览 0 评论 0原文

我正在开发一个应用程序,它使用 NSData 的 initWithContentsOfURL 方法从互联网下载一些数据。在启动时,我使用 Apple 的 Reachability 示例中的一些代码来检查 wifi 连接是否可用;如果没有,那么该应用程序只会显示一条错误消息并拒绝真正启动(按照我的客户的要求)。在 iPod 和 iPad 上一切正常,但在 iPhone 上,我的客户报告下载速度要慢得多,除非他打开飞行模式,在这种情况下,下载速度与 iPod / iPad 速度相当。因此,即使有 wifi 连接可用,iPhone 也可能使用蜂窝网络下载数据。这真的很奇怪。有谁知道我可能做错了什么?

I'm working on an application that downloads some data from the internet using NSData's initWithContentsOfURL method. At startup I'm using some code from Apple's Reachability sample to check if a wifi connection is available; if not, then the app just shows an error message and refuses to really start (as requested by my client). All is working fine on iPod and iPad, but on iPhone, my client reports much, much slower download speeds, unless he turns on airplane mode, in which case download speeds are on par with iPod / iPad speeds. So it seems that even though a wifi connection is available, the iPhone is probably using the cellular network to download the data. Which is really weird. Does anyone have any idea about what I might be doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流年里的时光 2024-10-08 06:49:31

我相信您的答案是您已经有权访问的 SCNetworkReachability因为您使用的是 Apple 的 Reachability 代码。

SCNetworkReachability API 允许应用程序确定系统当前网络配置的状态以及目标主机的可达性。 API 返回的标志之一 kSCNetworkReachabilityFlagsIsWWAN 将告诉您与目标主机的网络连接是否使用运营商网络。 Reachability 示例代码展示了如何确定活动网络连接。

如果您需要的话,您还可以使用它来强制执行 WiFi。
看看 UI需要持久WiFi

I believe your answer is SCNetworkReachability which you already have access to since you are using Apple's Reachability code.

The SCNetworkReachability API allows an application to determine the status of a system's current network configuration and the reachability of a target host. One of the flags returned by the API, kSCNetworkReachabilityFlagsIsWWAN, will tell you if a network connection to the target host uses the carrier network. The Reachability sample code shows how to determine the active network connection.

You could also use this to enforce WiFi if that's what you want.
Have a look at UIRequiresPersistentWiFi

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文