/*
1)OC中增加的数据类型
(1)Boolean类型
作用:用来存放逻辑值 真(非0) 假(0)
用来做判断
存放值为:true(真) false(假)
Boolean flag=true;
if(flag){
NSLog(@"真 %d",flag);
}
else{
NSLog(@"假 %d",flag);
}
BOOL flag2=YES;
if(flag2){
NSLog(@"真 %d",flag2);
}
else{
NSLog(@"假 %d",flag2);
}
2)OC中的异常机制
@try {
<#Code that can potentially throw an exception#>
}
@catch (NSException *exception) {
<#Handle an exception thrown in the @try block#>
}
@finally {
<#Code that gets executed whether or not an exception is thrown#>
}
*/
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
Boolean flag=true;
if(flag){
NSLog(@"真 %d",flag);
}
else{
NSLog(@"假 %d",flag);
}
BOOL flag2=YES;
if(flag2){
NSLog(@"真 %d",flag2);
}
else{
NSLog(@"假 %d",flag2);
}
}
return 0;
}
|
|