1.NSString创建
NSString *str1 = @"123";
NSString *str2 = [NSString stringWithString:str1];
NSString *str3 = [[NSString alloc]initWithString:str1];
NSString *str4 = [NSString stringWithFormat:@"%@", str1];
NSLog(@"str1---%p\nstr2---%p\nstr3---%p\nstr4---%p\n\n",str1,str2,str3,str4);
输出结果如下:
str1---0x100001058
str2---0x100001058
str3---0x100001058
str4---0x33323135
2.NSArray创建
NSArray *array0 = @[@"abc",@"def",@"1223"];
NSArray *array1 = [NSArray arrayWithArray:array0];
NSArray *array2 = [[NSArray alloc]initWithArray:array0];
NSLog(@"array0---%p\narray1---%p\narray2---%p",array0,array1,array2);
输出结果如下:
array0---0x102054020
array1---0x102054130
array2---0x1020541f0
网友评论