#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
//创建一个字符串常量
NSString *str=@"字符串";
// 创建一个空的字符串对象
//实例方法
NSString *str1=[[NSString alloc]init];
//类方法
NSString *str2=[NSString string];
//快速创建字符串
NSString *str3=[[NSString alloc]initWithString:@"zifuchuan"];
NSString *str4=[[NSString alloc]initWithString:str];
NSString *str5=[NSString stringWithString:@"zifuchuan"];
//格式化创建字符串
int num=23;
float num1=12.3;
NSString *str6=[[NSString alloc]initWithFormat:@"%d",num];
NSString *str7=[[NSString alloc]initWithFormat:@"这个数字是:%d或%f",num,num1];
NSLog(@"%@",str6);
NSLog(@"%@",str7);
NSString *str8=[NSString stringWithFormat:@"%d,%f",num,num1];
NSLog(@"%@",str8);
}
return 0;
}