After updating to XCode 6.3, compiler started giving this warning.
Comparison of address of \'myObject\' not equal to null pointer is always true.
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
There are four mistakes here. The first two are that you aren't setting any initial values for the CGRect and UIView variables, so there's no way to detect a failure. Try setting the CGRect to a zero-width, zero-height rect initially if you think that is useful, and set the UIView to nil.
The third and fourth mistakes are that the address of a local variable is never NULL. (Note that this is not true for global variables in libraries, as I mentioned in another comment—the address of an NSString pointer constant might be NULL if the symbol didn't exist on the version of the OS you're running—but for local variables, you're guaranteed an address up to the point where your stack overflows and your app crashes.)
I'm also puzzled by why you're calling a delegate method yourself. Normally, the OS itself calls those methods, so calling them yourself is somewhat atypical usage. To be fair, I've done it on occasion when a delegate method performs a computation that I need somewhere else in the code, and I've also done it when implementing delegates that call other delegates, but in the context of this question, it seemed like a potential mistake.
For the first instruction, a changed to :
if (!CGRectIsNull(anotherRect)) {
}