//
//main.m
//OC基本语法
//OC语言的第一次接触
//Created by side on 16/7/9.
//Copyright @2016 lanou.All rights reserved.
//
#import <Foundation/Foundation.h>
int main(int argc,const char*argv[]){
@autoreleasepool{
//insert code here...
NsLog(@"Hello,World!");
//OC基本语法
//整形(long型)NSInteger a = 10;
//打印
NSLog("@a=%ld",a);
//浮点型(double型)
CGFloat b=55.666;
NSLog(@"b=%2f",b);
//布尔型
BOOL flag = YES;
//字符串
NSString *str=@a淮南师范学院bcde";
//不管是英文还是中文长度都是1
NSLog(@"str的长度=%ld",str.length);
//字符串相等(全等 前缀 后缀)
//1全等
if([str isEqualToString:@"a"]{//判断前缀hasPrefixNSLog(@"前缀等于a);}
//3后缀相等
if([str hasSuffix:@“师范”]{//判断后缀hasSuffix NSLog(@"后缀等于师范”);}
else
NSLog(@"后缀不等于师范“);
if(str hasSuffix:@"de"]{
NSLog(@"后缀等于de");
else
NSLog(@"后缀不等于de");
//格式化创建字符串
NSString *str1 = [NSString stringWithFormal:@"%@+++++++",@im"];
NSLog(@str1=%@",str1);
NSLog(@"------------");
NSString *str2 =[NSString stringWithFormal:@"%@++++++++++",str];
NSLog(@"str1=%@",str2);
]
return 0;
}