Will a pointer to a pointer to zero correspond to NULL?

Example:

The validation method contains this validation to see if an NSError object should be created or not:

- (BOOL)validateCompanyName:(NSString *)newName error:(NSError **)outError { if (outError != NULL) { // do it... 

Now I am passing an NSError object, for example:

 NSError *error = nil; BOOL ok = [self validateCompanyName:@"Apple" error:&error]; 

I'm not sure if this matches the check, not NULL. I think this is not NULL, since I believe that NULL is not zero. Maybe someone can clean this up?

+4
source share
1 answer

nil (all lowercase letters) is a null pointer to an Objective-C object.

nil (capized) is a null pointer to an Objective-C class.

NULL (all caps) is a null pointer to anything else.

However, they all compile to 0 , so (nil == Nil == NULL == 0) (thanks Dave).

+6
source

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


All Articles