#import <Foundation/Foundation.h>
/*
*c语言拥有布尔数据类型,它具有true和false值,objective-c提供了相识的类型BOOL ,它具有YES 和NO值
*/
BOOL areIntsDifferent(int thing1,int thing2){
if(thing1==thing2){
return (NO);
}else {
return (YES);
}
}
/*
boolString()的返回类型是一个指向NSString的指针。这意味这函数会返回一个cocoa字符串,
*/
NSString *boolString(BOOL yesno){
if(yesno==NO){
return @"no";
}else{
return @"yes";
}
}
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
BOOL areTheyDifferent;
areTheyDifferent=areIntsDifferent(5,5);
NSLog(@"are %d and %d different? %@",5,5,boolString(areTheyDifferent));
areTheyDifferent=areIntsDifferent(6, 5);
/**
NSLog()的编写者添加%@格式说明符,是为了通知NSLog()接受适当的参数,将其作为NSString,再使用该字符串中的字符,并将其发送的控制台。
NSLog()中输出任何对象的值时,都会使用%@格式说明符。中使用这个说明符时,对象通过一个名为description的方法提供自己的NSLog()格式。
*/
NSLog(@"are %d and %d different ?%@ ",6,5,boolString(areTheyDifferent));
[pool drain];
return 0;
}