NSCLConnection的XCode 4警告“表达结果未使用” [英] XCode 4 warning "Expression result unused” for NSURLConnection

查看:256
本文介绍了NSCLConnection的XCode 4警告“表达结果未使用”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想做我惯常的数据传输。我定义了我的NSMutableURLRequest然后调用

I'm just trying to do my usual data transfert. I define my NSMutableURLRequest then call

[[NSURLConnection alloc] initWithRequest:request delegate:self];

这对于Xcode 3来说已经不错了,但是Xcode 4警告我该行上有 Expression results unused
请求确实有效,但我想找到一种摆脱警告的方法。

This used to be ok with Xcode 3 but Xcode 4 warns me about "Expression result unused" on that line. The request does work but I would like to find a way to get rid of the warning.

我想我可以将连接存储在变量中但是我我真的不需要它,我看不出将它设置为 nil 的下一行(虽然这会删除警告)

I suppose I could store the connection in a variable but I don't really need it and I can't see the point of setting it to nil the next line (although this would remove the warning)

请注意:我不是100%确定它是否是XCode 4或启用ARC的事实。

Please note: I'm not 100% sure if it's XCode 4 or the fact ARC is enabled.

非常感谢您的帮助!

推荐答案

当函数返回不需要的结果时,可以将其转换为void以消除编译器警告:

When a function returns a result that you don't need you can cast it to void to eliminate the compiler warning:

(void) [[NSURLConnection alloc] initWithRequest:request delegate:self];

我还没有使用ARC,所以我不能说这是不是一个好主意,之前ARC需要将此指针结果保留在某处,以便释放它。

I haven't used ARC yet so I can't say if this is a good idea, before ARC you would need to keep this pointer result somewhere so you could release it.

这篇关于NSCLConnection的XCode 4警告“表达结果未使用”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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