zoukankan      html  css  js  c++  java
  • OC基础复习02-BOOL

    首先看下objc.h里面的定义

     1 /// Type to represent a boolean value.
     2 #if !defined(OBJC_HIDE_64) && TARGET_OS_IPHONE && __LP64__
     3 typedef bool BOOL;
     4 #else
     5 typedef signed char BOOL; 
     6 // BOOL is explicitly signed so @encode(BOOL) == "c" rather than "C" 
     7 // even if -funsigned-char is used.
     8 #endif
     9 
    10 #if __has_feature(objc_bool)
    11 #define YES __objc_yes
    12 #define NO  __objc_no
    13 #else
    14 #define YES ((BOOL)1)
    15 #define NO  ((BOOL)0)
    16 #endif

    从上面的定义我们发现布尔变量的值为 YES/NO,或 1/0 。YES 或 1 代表真,NO 或 0 代表假。比如你定义了一个布尔变量并赋了值

    因此我们可以定义 BOOL b1 = YES;  BOOL b2 = NO; 或者定义BOOL b3 = 1; BOOL b4 = 0;

  • 相关阅读:
    VueBlog
    java 代理模式
    集合框架
    面试题
    java 多线程
    网络编程
    HTTP
    MAVEN
    Redis高级
    深入浅出--梯度下降法及其实现
  • 原文地址:https://www.cnblogs.com/greenboy/p/4611349.html
Copyright © 2011-2022 走看看