I find some time ago the enum kNilOptions which is equal to 0.
I try to make my code the most readable but I wonder what is best to use when you have methods that take an option parameter, for example :
[NSData dataWithContentsOfFile:imageURL.path
options:kNilOptions
error:&error];
I usually see nil in a lot of code I read but I think kNilOptions would be more accurate. I don't see often (almost never) kNilOptions. Is there a reason for that?
Do you think it is ok to use it or is it better to stick to simply nil?
I think 0 is more readable than kNilOptions and there is some evidence that kNilOptions is "old".
You should use nil to represent uninitialized Objective-C object references and NULL for uninitialized C pointers (void *, char *, etc).
Use 0 if the options doesn't provide a "none value", which is the case for options NSDataReadingOptions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With