我正在尝试编写一个 iOS 应用程序,它发出异步请求以通过网络获取数据.似乎很多人为此推荐使用 NSURLConnection,并且经常提到委托方法 connection:didReceiveData:.
I'm trying to write an iOS app that makes asynchronous requests to get data over the network. It seems like a lot of people recommend using NSURLConnection for this, and frequently mention the delegate method connection:didReceiveData:.
不幸的是,我终生无法找到此委托方法的文档记录.一方面,它不在 NSURLConnectionDelegate 的协议参考.它列在 NSURLConnection 类参考,但显然在 iOS5 中已被弃用.该文档没有解释为什么它被弃用,或者开发人员应该使用什么来实现类似的功能.
Unfortunately, I cannot for the life of me find out where this delegate method is documented. For one, it is not in the protocol reference for NSURLConnectionDelegate. It is listed in the NSURLConnection Class Reference, but has apparently been deprecated as of iOS5. The documentation does not explain why it was deprecated, or what developers should use instead to achieve similar functionality.
我错过了什么?我读过的很多内容似乎暗示了对 iOS5 的 NSURLConnection 进行了重大更改.这些更改记录在哪里?委托方法的文档是否完整?
What am I missing? A lot of what I've read seems to imply that big changes were made to NSURLConnection for iOS5. Where are these changes documented? Is the documentation of delegate methods complete?
谢谢
搜索头文件告诉我,这些方法已从非正式协议(这是一种已弃用的 Obj-C 模式)转移到名为 NSURLConnectionDataDelegate
位于 NSURLConnection.h
中,但没有公共文档.
Fishing around the header files tells me that the methods were moved from an informal protocol (which is a deprecated Obj-C pattern) into a formal delegate protocol called NSURLConnectionDataDelegate
that's in NSURLConnection.h
, but doesn't have a public documentation.
文档的其余部分继续使用以前的方法,所以我猜这是文档中的一个遗漏.IE.这些方法(大部分)不会去任何地方,它们只是被改组为几个协议,文档团队一直在懈怠.尝试使您的委托对象符合适当的协议,并使用头文件中的签名实现方法.
The rest of the documentation keeps using the methods as before, so my guess is this is an omission in the documentation. I.e. the methods (mostly) aren't going anywhere, they were just reshuffled into several protocols and the documentation team has been slacking off. Try making your delegate object conform to the appropriate protocol, and implement the methods with the signatures from the header file.
这篇关于不推荐使用 iOS5 NSURLConnection 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!