[Objective-C] BOOL类型
来源:互联网 发布:华中地区数据科学会议 编辑:程序博客网 时间:2024/04/27 22:14
参考:http://code.tutsplus.com/tutorials/objective-c-succinctly-data-types--mobile-21986
Object C自己定义了布尔类型:BOOL。它可以取两个值:YES 和 NO
在 /usr/include/objc/objc.h 中可以看到,它们的值分别为 1 和 0,然而,任何大于0值都可以看做YES
#import <objc/objc-api.h>typedef struct objc_class *Class;typedef struct objc_object { Class isa;} *id;typedef struct objc_selector *SEL;typedef id (*IMP)(id, SEL, ...);typedef signed char BOOL;#define YES (BOOL)1#define NO (BOOL)0#ifndef Nil#define Nil 0 /* id of Nil class */#endif#ifndef nil#define nil 0 /* id of Nil instance */#endifNSLog()函数中BOOL类型的占位符是"%i",如:
BOOL isHuman = 127;if (isHuman) { // This will execute. NSLog(@"isHuman is TRUE");}if (isHuman == YES) { // But this *won't* execute. NSLog(@"isHuman is YES");}其中的isHuman的条件满足,而isHuman == YES的条件不满足。
0 0
- [Objective-C] BOOL类型
- 再谈Objective C中的BOOL类型
- 再谈Objective C中的BOOL类型
- Objective-C中的BOOL类型各种转换
- 一起来学Objective-C(4)——BOOL类型
- Objective-c中的占位符,打印BOOL类型数据
- Objective-c中的占位符,打印BOOL类型数据
- Objective-C中的占位符,打印BOOL类型数据
- Objective-c中的占位符,打印BOOL类型数据
- Objective-c中的占位符,打印BOOL类型数据
- 【iOS开发之Objective-C】布尔(Boolean)类型--BOOL
- objective-c 学习之旅之BOOL类型
- Objective-C 中的BOOL
- Objective C 中 BOOL与bool
- c的bool类型
- C语言bool类型
- C 语言bool类型
- C语言 bool类型
- HBase协处理器及实例
- Rock, Scissors, Paper(模拟)
- 数学之美笔录(2):中文分词
- 绘制图形-移动,旋转,阴影,渐变
- [python]用profile协助程序性能优化
- [Objective-C] BOOL类型
- Linux服务器意外关机,开机提示一下信息:an error occurred during the file system check.
- 《Java课程实习》日志(周二)
- 菜鸟上路
- 莫名其妙问题
- UITextField的leftView不贴边处理
- 黑马程序员——Java基础---反射
- dll项目中_declspec(dllimport)和_declspec(export)使用
- OJ第三批——Problem R:P3 数钱是件愉快的事