在 Xcode Documentation : URL Loading System Programming Guide : Using NSURLConnection 中的示例中,他们分配
一个NSURLConnection
(theConnection
),然后在回调中释放它:-connection:didFailWithError:
& -connectionDidFinishLoading:
。但是,如果在调用任一回调方法之前释放委托(delegate),theConnection
不会泄漏(即永远不会释放)吗?
最佳答案
不,theConnection
不会泄漏,因为 Xcode Documentation for -[NSURLConnection initWithRequest:delegate:]
“特殊注意事项”下指出:“连接保留委托(delegate)。当连接完成加载、失败或取消时,它会释放委托(delegate)。”
关于iphone - NSURLConnection 固有的内存泄漏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6222687/