It is found that many beginners cannot differentiate bool, bool, and class types. Today, I am free to write a blog post to differentiate them.
1. bool is a boolean type of C language, with true and false, bool is a boolean type of Objective C language, with Yes and no, because OC can be mixed with C, so bool and bool can appear in the code at the same time.
2. In-depth analysis of bool:
Bool is actually a signed character type, and the storage space is 8 bits. Therefore, if a 32-bit integer is assigned to bool, only the last 8 bits will be taken.
In the bool type, "yes" is defined as 1, and "no" is defined as 0. when data is stored in the internal storage, "yes" or "no" is not saved. Therefore, if the last eight digits are zero after a value assignment, the Boolean value is no.
3. Sel type
Corresponding to functions in oC
4. class type
It is used to indicate a class name. After the class is created, we can regard the class as the class of the object.
For example:
[Class or object class]; [class or object superclass]; nsclassfromstring (method name string );
<Span style = "font-family: kaiti_gb2312; font-size: 18px;"> class class1 = [nsstring class]; nsdictionary * A = [nsdictionary new]; class class2 = [A Class]; Class class3 = [A superclass]; Class class4 = [nsdictionary superclass]; Class class5 = nsstringfromclass (@ "nsstring"); </span>