iOS中boolean、Boolean、BOOL、bool的区别

iOS中boolean、Boolean、BOOL、bool的区别

 

 

  1. bool t1 =1;//true or false  
  2. BOOL t2 = 3;//YES or NO  
  3. Boolean t3 =1; //unsigned char type  
  4. boolean_t t4 = 1;//int type  
  5. NSAssert(t1,@"bool t1 is NO");//通过测试  
  6. NSAssert(t2,@"BOOL t2 is NO");//通过测试  
  7. NSAssert(t3,@"Boolean t3 is NO");//通过测试  
  8. NSAssert(t4,@"boolean_t t4 is NO");//通过测试  

 

bool 是int型,bool b 当b!=0 有 b=true

BOOL 是unsigned char型,BOOL b 当b=1 有 b=YES

Boolean 是char型

boolean_t 是int型

注意:上述类型作为判断条件时只要变量值不为零,则条件成立。

posted @ 2015-09-08 11:17  heyuan123  阅读(663)  评论(0编辑  收藏  举报