1 .Objective-C也提供了一个相似的类型BOOL,它具有YES和NO两个值。(C语言拥有布尔数据类型bool,它具有true和false两个值)
2. 下面是例子
//
// main.m
// BOOL Party
//
// Created by josephvitt on 2017/6/29.
// Copyright © 2017年 josephvitt. All rights reserved.
//
#import <Foundation/Foundation.h>
//return NO if the two integers have the same
//value,YES otherwise
BOOL areIntsDifferent(int thing1,int thing2){
if (thing1 == thing2) {
return (NO);
}else{
return (YES);
}
}//areIntsDifferent
//given a NO value ,return the human-readable
//string "NO" .otherwise return "YES"
NSString *boolstring(BOOL yesNo){
if(yesNo == NO){
return(@"NO");
}else{
return (@"YES");
}
}//boolstring
int main(int argc, const char * argv[]) {
BOOL areTheyDifferernt;
//areTheyDifferernt = areIntsDifferent(5, 5);
areTheyDifferernt = areIntsDiffer