我下各种功能使用此行代码在我的项目的许多地方iPhone(目标C):如何释放NSURLConnection的在
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest: theRequest delegate:self];
现在我得到一个平常警告“未使用的变量theConnection ”。 我也知道它的内存泄漏。
可以使用下面的代码吗?
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest: theRequest delegate:self];
[theConnection release];
如果我释放连接对象,会在didReceiveData,connectionDidFinishLoading等委托方法中出现问题吗?
如果上面的语句可以解决内存泄漏没有问题如何摆脱警告“未使用变量等等等等。”?
请问这行:“[[NSURLConnection的alloc] initWithRequest:请求委托:自];' 不泄漏内存? – necixy 2011-04-14 11:03:21
是这就是为什么我给你我的回答中的另一个选项 – visakh7 2011-04-14 11:12:59
如果我使用'[[NSURLConnection alloc] initWithRequest:request delegate:self];'而不是'NSURLConnection * theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self] ;'然后使用分析仪我得到有关潜在的内存泄漏的警告。 :( – necixy 2011-04-14 12:01:07