Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Just trying to figure out what's the best practice: when using method that takes (NSError**), is it better to send it nil or NULL?

For example,

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

In the documentation it says "You may specify nil for this parameter if you do not want the error information." On the other hand, since its a double pointer, NULL seems to make sense as well?

like image 483
Joseph Lin Avatar asked Oct 13 '11 02:10

Joseph Lin


1 Answers

Technically, NULL is the right answer and the docs are wrong.

In practice, it matters not. NULL and nil are the same, for all intents and purposes.

While that could change and remain language compliant, it couldn't change without breaking tons and tons of stuff.

Feel free to file a bug, though.

like image 54
bbum Avatar answered Oct 06 '22 17:10

bbum