Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Objective-C use YES and NO instead of 1 and 0? [closed]

Tags:

objective-c

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?

like image 872
Michael Avatar asked Mar 27 '09 18:03

Michael


People also ask

What does @() mean in Objective-C?

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.

Is yes or no boolean data?

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.

Is C faster than Objective-C?

Objective-C is slightly slower than straight C function calls because of the lookups involved in its dynamic nature.

How do you free an object in Objective-C?

The correct way is to do this: self. printButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(printWebPage:)] autorelease];


1 Answers

Making it more readable is a technical reason.

like image 114
Aaron Maenpaa Avatar answered Sep 23 '22 02:09

Aaron Maenpaa