XCode 6.3警告:'myObject'的地址不等于空指针的比较始终为true [英] XCode 6.3 Warning : Comparison of address of 'myObject' not equal to null pointer is always true

查看:175
本文介绍了XCode 6.3警告:'myObject'的地址不等于空指针的比较始终为true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新到XCode 6.3后,编译器开始发出此警告。

After updating to XCode 6.3, compiler started giving this warning.

'myObject'的地址不等于空指针的比较始终为真。

这是我的一段代码,

用它抓我的头,但没有找到任何解决方案或解决方法来摆脱这个警告。

Scratching my head with it, but didn't find any solution or workaround to get rid of this warning.

我的问题与此处。但是,使用的答案无法解决。

My question is linked with question over here. But, it can't be solved using answer discussed.

欢迎任何帮助:)

推荐答案

检查指针的正确方法是

if (anotherInView != nil) {
}

您正在将变量的地址与 NULL进行比较。每个变量都有一个地址,你不能拥有一个地址为 NULL 的变量,你可以得到一个值为 NULL的变量

You are comparing address of a variable with the NULL. Every variable has an address you can't have a variable whose address is NULL, you can have a variable whose value is NULL

此外 anotherRect!= NULL 再次无效。 anotherRect 将始终有一个值,因为它是 struct

Also anotherRect != NULL is again not valid. anotherRect will always have a value as it's a struct

这篇关于XCode 6.3警告:'myObject'的地址不等于空指针的比较始终为true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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