Objective-C Boolean and class and SEL types

Source: Internet
Author: User
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>


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.