Why can't we use the negation operator when checking for a character?

The answer is a question that if (x != nil)matches with if (x).

But the Apple Documentation says:

Note. When checking for a character, you must explicitly compare it to NULL or zero in the code. You cannot use the negation operator (!) To nullify the address of a character.

Which seems to contradict "Working with Zero" from https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithObjects/WorkingwithObjects.html#//apple_ref/doc/uid/TP40011210- -SW22

+4
source share
2

, . , :

if (!MyWeakLinkedFunction) {
    // symbol doesn't exist
}

:

if (MyWeakLinkedFunction == NULL) {
    // symbol doesn't exist
}

:

if (MyWeakLinkedFunction) {
    // symbol exists
}

if (MyWeakLinkedFunction != NULL) {
    // symbol exists
}
+3

, .

NULL .

: ( ), NULL NIL

(!), .

, , ( ).

, , , -

. , NULL . (!) , . C . , & myFunction myFunction.

+1

Source: https://habr.com/ru/post/1623024/


All Articles