不推荐使用iOS5 NSURLConnection方法 [英] iOS5 NSURLConnection methods deprecated

查看:121
本文介绍了不推荐使用iOS5 NSURLConnection方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个iOS应用程序,该应用程序通过网络发出异步请求以获取数据。似乎有很多人建议使用NSURLConnection,并经常提到委托方法连接: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.

其余文档一如既往地使用这些方法,所以我猜这是文档中的遗漏。即这些方法(大多数)不会去任何地方,它们只是被重新调整为几个协议,文档团队一直在懈怠。尝试使您的委托对象符合相应的协议,并使用头文件中的签名实现这些方法。

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方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆