XCode 6.3 Warning : Comparison of address of 'myObject' not equal to null pointer is always true

后端 未结 3 966
情书的邮戳
情书的邮戳 2021-01-17 19:58

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

Comparison of address of \'myObject\' not equal to null pointer is always true.

3条回答
  •  无人及你
    2021-01-17 20:12

    Correct way of checking the pointer is

    if (anotherInView != nil) {
    }
    

    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

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

提交回复
热议问题