NSURLConnection和XCode“建立并分析"; [英] NSURLConnection and XCode "Build and Analyze"
问题描述
我一直在遵循使用 NSURLConnection ,并且正在使用委托来管理连接(在其他方法中,覆盖: didFailWithError:
和 connectionDidFinishLoading:
).在这些委托方法中释放为 NSURLConnection
对象分配的内存.
I have been following the documentation for using NSURLConnection and am using delegates for managing the connection (overriding among other methods connection: didFailWithError:
and connectionDidFinishLoading:
). The memory allocated for the NSURLConnection
object is released in those delegate methods.
我的问题是,从XCode菜单运行构建/构建和分析"会在 NSURLConnection
上调用alloc的方法中触发令人讨厌的对象潜在泄漏(...)"警告.类(从逻辑上讲,因为我不在同一块中释放它).
My problem is that running "Build/Build and Analyze" from the XCode menu triggers an annoying "Potential leak of an object (...)" warning in the method calling alloc on the NSURLConnection
class (logically enough as I do not release it in the same block).
有没有办法消除此警告?
Is there a way to silence this warning?
推荐答案
将连接对象存储在保留的实例变量中的方法.然后,您可以在第一种方法结束时安全地释放它.
The way round this to store the connection object in a retained instance variable. Then you can safely release it at the end of your first method.
这篇关于NSURLConnection和XCode“建立并分析";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!