可能重复:
Objective C NSString* property retain count oddity
NSString retain Count
NSString *a=[[NSString alloc] initWithString:@""];
NSLog(@"%d",[a retainCount]);
每个人都希望计数应为0,但它给出了2147483647
然后我尝试释放再次给出相同的输出没有减少
NSString *a=[[NSString alloc] initWithString:@""];
[a release];
[a release];
[a release];
[a release];
[a release];
[a release];
[a release];
NSLog(@"%d",[a retainCount]);
很好的尝试没有分配同样的
NSString *a=@"";
NSLog(@"%d",[a retainCount]);
请让我知道原因是什么?
感谢4个回答