求大神指教,s2,s3,s5的值为什么是这样的?
NSString *s1 = @"abc";
NSString *s2 = [NSString stringWithFormat:@"age is %d",10];
NSString *s3 = [[NSString alloc] initWithFormat:@"age is %i",20];
NSString *s5 = [[NSString alloc] initWithFormat:@"age is %i",30];
NSMutableString *s4 = [s2 mutableCopy];
NSLog(@"s1 = %zi",s1.retainCount);
NSLog(@"s2 = %zi",s2.retainCount);
NSLog(@"s3 = %zi",s3.retainCount);
NSLog(@"s5 = %zi",s5.retainCount);
NSLog(@"s4 = %zi",s4.retainCount);
运行出来的结果:
2015-09-13 20:26:24.251 copy[1594:137828] s1 = -1
2015-09-13 20:26:24.252 copy[1594:137828] s2 = -1
2015-09-13 20:26:24.252 copy[1594:137828] s3 = -1
2015-09-13 20:26:24.252 copy[1594:137828] s5 = 1
2015-09-13 20:26:24.252 copy[1594:137828] s4 = 1 |
|