最新的Reachability.m(示例代码版本2.2)与iOS 3.0兼容吗?

发布于 2024-10-27 23:11:27 字数 292 浏览 2 评论 0原文

有谁知道 Apple 的 iOS“Reachability”示例代码的 2.2 版(最新)是否可以在 iOS 3.0 上运行? 我想支持 iOS 3.0,而 Reachability.h 和 .m 是我在应用程序中使用的第一个非框架代码。在我自己的代码中,我通常会阅读我使用的所有方法的文档,并使用 respondsToSelector: 来实现无法在 3.0 上运行的方法。 当人们使用第三方代码时,他们如何确认它支持哪个 iOS,而不需要根据文档单独检查每个方法?

或者,有谁知道我如何获得旧版本的示例代码? (可达性版本 2.1 可能会有所帮助。)

Does anyone know if version 2.2 (the latest) of Apple's iOS 'Reachability' example code will run on iOS 3.0?
I want to support iOS 3.0, and Reachability.h and .m is the first non framework code I'm using in my app. In my own code I usually read the docs for all methods I use, and use respondsToSelector: to implement methods that won't run on 3.0.
When people use third party code, how do they confirm which iOS it supports without checking every method individually against the docs?

Alternatively, does anyone know how I can get my hands on the old version of the example code? (Reachability version 2.1 might help.)

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

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

发布评论

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

评论(1

入画浅相思 2024-11-03 23:11:27

我并不是想拒绝@Matt 和@Martin 的回答,但我觉得这个问题值得后人回答。如果他们回来发表评论作为答案,请随意接受。

不管怎样,我自己的答案是,我强烈建议不要在生产应用程序中直接使用Apple示例项目,尤其是Reachability。他们的许多示例写得很糟糕,而且正如您所注意到的,已经过时了。我已经向他们提交了很多错误,但没有得到很多结果。

也就是说,另一点是,在依赖 Reachability 进行控制逻辑时,您真的应该三思而后行。如果您只想在连接发生变化或其他情况时通知用户,也可以。但不要依赖 Reachability 所说的内容来决定是否尝试与网络通信。您的网络状态通常是错误的。只需打开一个连接,如果成功就很好,否则您将收到错误响应,让您知道没有连接。

编辑 - 关于您关于如何判断第三方应用程序支持哪些 IOS 的其他问题。答案是,除非他们已经记录下来,否则您可能无法做到。最好的指标通常是查看构建目标的“Base SDK”和“iOS Deployment Target”设置。 Base SDK 将是他们构建的最新 iOS 版本,而 Deployment Target 将是他们支持的最早的 iOS 版本。

干杯

I don't mean to snipe an answer from @Matt and @Martin, but I feel like this question deserves an answer for posterity. If they come back and post their comments as answers please feel free to accept them.

Anyway, my own answer is that I would highly advise against using Apple sample projects directly in a production application, especially Reachability. Many of their examples are badly written and, as you've noticed, outdated. I've filed a lot of bugs against them without many results.

That said, one other point is that you should really think twice about relying on Reachability for control logic. If you just want to notify the user when their connection changes or something, okay. But don't rely on what Reachability says to decide whether to try communicating with the network or not. It's often wrong about your network status. Just open up a connection, and if it succeeds great, otherwise you'll get an error response letting you know there's no connection.

EDIT - Regarding your other question about how to tell what IOS a third party app supports. The answer is, unless they've documented it, you might not be able to. Best indicator is usually taking a look at the build target's "Base SDK" and "iOS Deployment Target" settings. Base SDK will be the latest iOS version they've built against, and Deployment Target will be the earliest iOS version they support.

Cheers

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