"error: NULL" or "error: nil"?

Just trying to figure out what is best: when using a method that accepts (NSError**) , is it better to send it nil or NULL ?

For example,

NSArray *items = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:NULL];

The documentation says: "You can specify nil for this parameter if you do not want to receive error information." On the other hand, since its a double pointer, does NULL seem to make sense?

+7
source share
1 answer

Technically, NULL is the correct answer, and the documents are erroneous.

In practice, this does not matter. NULL and nil same for all goals and purposes.

While this can change and remain compatible with the language, it cannot change without breaking a ton and ton of material.

Feel free to write down the error.

+10
source

All Articles