Objective-C Boolean Type & amp; #160; and class, SEL type

Source: Internet
Author: User

Objective-C Boolean Type & #160; and class, SEL type
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 );

Class class1 = [NSString class]; NSDictionary * a = [NSDictionary new]; Class class2 = [a class]; Class class3 = [a superclass]; class class4 = [NSDictionary superclass]; Class class5 = NSStringFromClass (@ "NSString ");


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.