【发布时间】:2011-04-14 10:32:26
【问题描述】:
我在项目的很多地方都在各种功能下使用过这行代码:
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest: theRequest delegate:self];
现在我收到一个常见的警告“未使用的变量 theConnection”。 我也知道它的内存泄漏。
可以使用下面的代码吗?
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest: theRequest delegate:self];
[theConnection release];
如果我释放 Connection 对象,didReceiveData、connectionDidFinishLoading 等委托方法会出现问题吗?
如果上述语句可以毫无问题地解决内存泄漏,如何摆脱警告“未使用的变量等等等等”?
【问题讨论】:
标签: iphone objective-c nsurlconnection