iphone - NSURLConnection 固有的内存泄漏?
<p><p>在 <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html" rel="noreferrer noopener nofollow">Xcode Documentation : URL Loading System Programming Guide : Using NSURLConnection</a> 的示例中,他们 <code>alloc</code> 一个 <code>NSURLConnection</code> (<code>theConnection</code>) 然后在回调中释放它: <code>-connection:didFailWithError:</code> & <code>-connectionDidFinishLoading:</code>。但是,如果委托(delegate)在任一回调方法被调用之前被释放,<code>theConnection</code> 不会泄漏(即永远不会被释放)吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>不,<code>theConnection</code> 不会泄漏,因为 <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html" rel="noreferrer noopener nofollow">Xcode Documentation for <code>-</code></a>特殊注意事项下的状态:“连接保留委托(delegate)。它在连接完成加载、失败或被取消时释放委托(delegate)。”</p></p>
<p style="font-size: 20px;">关于iphone - NSURLConnection 固有的内存泄漏?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/6222687/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/6222687/
</a>
</p>
页:
[1]