Objective-C中的bool,Boolean和BOOL之间有什么区别吗? [英] Is there any difference between bool, Boolean, and BOOL in Objective-C?

查看:103
本文介绍了Objective-C中的bool,Boolean和BOOL之间有什么区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道BOOL实际上是带符号char的typedef,但是布尔值呢?

I know BOOL is actually a typedef of signed char, but what about Boolean?

bool,Boolean和BOOL有什么区别?

What is the difference between bool, Boolean and BOOL?

推荐答案

Boolean是旧的Carbon关键字(历史Mac类型),定义为unsigned char. BOOL是定义为signed char的Objective-C类型. bool_Bool标准C类型的定义版本.它定义为int.使用BOOL.

Boolean is an old Carbon keyword (historic Mac type), defined as an unsigned char. BOOL is an Objective-C type defined as signed char. bool is a defined version of the _Bool standard C type. It's defined as an int. Use BOOL.

编辑(2019):苹果在某些新文档中讨论了BOOL的基础实现.基本上,在macOS上,BOOL最终仍然是signed char,但是在iOS和相关平台上,它下面是本机C bool.

Edit (2019): Apple talks about the underlying implementation of BOOL in some new documentation. Basically, on macOS, BOOL is still ultimately a signed char, but on iOS and related platforms, it a native C bool underneath.

这篇关于Objective-C中的bool,Boolean和BOOL之间有什么区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆