NSURLConnection和XCode“建立并分析"; [英] NSURLConnection and XCode "Build and Analyze"

查看:49
本文介绍了NSURLConnection和XCode“建立并分析";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在遵循使用 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屋!

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