#define _UIKeyboardFrameEndUserInfoKey (&UIKeyboardFrameEndUserInfoKey != NULL ? UIKeyboardFrameEndUserInfoKey : @"UIKeyboardBoundsUserInfoKey")
这段代码我知道是什么意思,但是不明白为什么判断是不是NULL的时候要对变量先取址?我自己写代码测试时会有警告,说拿地址跟非NULL比较永远都是true
大家讲道理2017-04-18 09:47:40
好吧,睡了一覺起來,發現同樣的問題在爆棧上已經有大神回覆我了,我就貼在這裡好了……在爆棧上我問的是為啥他要用地址去和NULL比較,然後被人修改為了為何要用常數的位址去跟NULL比較?因為那個UIKey.....確實是常數
好下面是我認為解決我問題的回复“Comparing the address of a constant (or function) to null is generally used to determine if the constant is defined.
You're getting the warning because the SDK that you're building against (minimum target version) has the constant defined, so it will always evaluate to true (the address won't be null)。 of iOS that doesn't have the constant defined, it will not be true (the address will be null).
If you lowered the target version to a version below where the constant were defined, it would weakly link to that SDK, and you would no longer receive the warning.」