iPhone 登录通知
有一个与使用异步 NSURLConnection 的 iPhone 登录身份验证最佳实践相关的问题。
由于使用相同的委托登录服务器,人们如何区分身份验证请求返回的通知和后续数据请求收到的数据?
谢谢,
Sj
Had a question related to best practices in iPhone login authentication using asynchronous NSURLConnection.
Since the same delegate is used for logging into a server, how do folks differentiate notifications coming back for an authentication request, versus when you recieve data for subsequent data requests?
Thanks,
Sj
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您所说的身份验证是指 HTTP 身份验证,那么该身份验证不会作为数据返回给您。 它在
-connection:didReceiveAuthenticationChallenge:
中返回。 如果您正在谈论管理 HTTP 层之上的身份验证的更高级别协议,那么您的工作就是跟踪连接的当前状态。请参阅使用NSURLConnection 了解有关 HTTP 身份验证的完整详细信息。
If by authentication, you mean HTTP authentication, then that is not handed back to you as data. It comes back in
-connection:didReceiveAuthenticationChallenge:
. If you're talking about a higher-level protocol that manages authentication above the HTTP layer, then it's your job to keep track of the current state of your connection.See Using NSURLConnection for full details on HTTP Auth.
使用的常见模式是为每种类型的请求创建一个不同的类,并使其管理自己的 NSURLConnection 生命周期。 然后它可以将事件发送回其委托。
另一种方法是记住您创建的所有 NSURLConnection 并将它们与委托回调的第一个参数进行比较。
The common pattern to use would be to create a different class for each type of request you have and make it manage the lifetime its own
NSURLConnection
. It can then send events back to its delegate.The other method would be to remember all the
NSURLConnection
s you've created and compare them against the first parameter of the delegate callbacks.