Web 服务应用程序的 iOS 应用程序架构
我正在开发一个应用程序,它是客户端并与网络服务进行通信。我正在使用 Reachability 类检查互联网连接。如果可用,我将布尔值设置为“是”,将“否”设置为默认值。
在我的应用程序委托的 didFinishLaunchingWithOptions
方法中,我获取一个单例对象并将其添加用于观察网络状态变化,以便它可以快速将 bool 转换为 YES。
当我的第一个 viewDidLoad
时,我尝试从 Web 服务 getToken
,因此我检查 internetConnection
是否可用,并且它总是返回 NO,因为我的对象获取我尝试获取令牌后收到通知。我认为使用延迟的表演者不是一个好主意,所以我该如何处理这种情况。提前谢谢..
I am developing an application which is a client and is communicating with a web service. I am checking internet connection with Reachability class. If its avaliable, I set a bool as YES, its NO as default.
In my application delegate's didFinishLaunchingWithOptions
method, I grab a singleton object and add it for observing network status changes so it can turn bool into YES quickly.
When my first viewDidLoad
, I try to getToken
from web service so I check if internetConnection
is avaliable and it always returns NO because my object gets a notification after I tried to get a token. I don't think its a good idea use a delayed performer, so how can I handle that situation. Thank in advance..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的情况下,我使用了 ASIHTTPRequest 库来检查请求是否到达服务器。 ASIHTTPRequest 提供了很多方法,包括这个:
要测试连接,您可以执行以下操作:
in your case, i have used the
ASIHTTPRequest
library to check either the request was reaching the server or not. The ASIHTTPRequest offers a lot of methods including this one :To test the connection, you can do something like this :