Is there any technical reason why Objective-C uses YES and NO instead of 1 and 0, or is it simply to make it more readable?
It's Shorthand writing. In Objective-C, any character , numeric or boolean literal prefixed with the '@' character will evaluate to a pointer to an NSNumber object (In this case), initialized with that value. C's type suffixes may be used to control the size of numeric literals.
By convention, we use the BOOL type for Boolean parameters, properties, and instance variables and use YES and NO when representing literal Boolean values. Because NULL and nil zero values, they evaluate to “false” in conditional expressions.
Objective-C is slightly slower than straight C function calls because of the lookups involved in its dynamic nature.
The correct way is to do this: self. printButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(printWebPage:)] autorelease];
Making it more readable is a technical reason.
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