NSURLConnection固有的内存泄漏? [英] NSURLConnection inherent memory leak?

查看:33
本文介绍了NSURLConnection固有的内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Xcode文档中的示例中URL加载系统编程指南:使用NSURLConnection ,它们分配一个 NSURLConnection ( theConnection ),然后在回调中释放它: -connection:didFailWithError:& -connectionDidFinishLoading:.但是,如果在调用任一回调方法之前就释放了委托, theConnection 不会泄漏(即永远不会被释放)吗?

In the example in the Xcode Documentation : URL Loading System Programming Guide : Using NSURLConnection, they alloc an NSURLConnection (theConnection) and then release it in the callbacks: -connection:didFailWithError: & -connectionDidFinishLoading:. But, won't theConnection leak (i.e. never get released) if the delegate is released before either of the callback methods get called?

推荐答案

不, theConnection 不会泄漏,因为作为

No, theConnection won't leak because, as the Xcode Documentation for -[NSURLConnection initWithRequest:delegate:] states under Special Considerations: "The connection retains delegate. It releases delegate when the connection finishes loading, fails, or is canceled."

这篇关于NSURLConnection固有的内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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