Objective-C 中的 BOOL
2016-03-02 21:30
253 查看
之前开发了一个针对单个数据模型,自动建表、增删改查等操作的 ORM 库,后边在 iPhone 5c 上使用时,出现了 crash 的情况。
经定位,问题就出在了模型中的 BOOL 类型的属性上。
看下 BOOL 在 objc.h 中的定义:
显而易见,在64位系统下,实际上时 bool 类型;而在32位系统下,是 signed char 类型的。
经定位,问题就出在了模型中的 BOOL 类型的属性上。
看下 BOOL 在 objc.h 中的定义:
/// Type to represent a boolean value. #if (TARGET_OS_IPHONE && __LP64__) || TARGET_OS_WATCH #define OBJC_BOOL_IS_BOOL 1 typedef bool BOOL; #else #define OBJC_BOOL_IS_CHAR 1 typedef signed char BOOL; // BOOL is explicitly signed so @encode(BOOL) == "c" rather than "C" // even if -funsigned-char is used. #endif
显而易见,在64位系统下,实际上时 bool 类型;而在32位系统下,是 signed char 类型的。
相关文章推荐
- objective-c中对类别category的理解
- K-means: optimization objective(最小化cost function来求相应的参数)
- 在Objective-C中,字符串的搜索
- iOS中的 多线程- NSThread 与 NSObject
- ActiveXObject 对象 (JavaScript)
- [iOS]编写高质量的Objective-C代码
- Objective-C 中的字符串比较
- Objective-C 和 Core Foundation 对象相互转换的内存管理总结
- JavaScript对象(Object)
- flask源码笔记:三,app.py模块(2)——Flask的基类_PackageBoundObject
- Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server
- iOS中使用JavaScriptCore实现Objective-C和JavaScript的相互调用
- Objective-C Runtime 相关资料
- object-c中的类目,延展,协议
- reason: Attempted to dereference an invalid ObjC Object or send it an unrecognized selector.
- reason: Attempted to dereference an invalid ObjC Object or send it an unrecognized selector.
- objectiveC修饰符 static extern const
- Objective-C Class 、 MetaClass、实例 详解
- IOS--Operation Object基础
- UIWebView 与 JS 交互(1):Objective-C 调用 Javascript