当我创建一个对象并检查其保留计数时,我得到了预期的 1。当我释放对象然后再次检查保留计数时,它仍然是1。对象不应该被释放,保留计数为0吗?
NSMutableString *str=[[NSMutableString alloc] initWithString:@"hello"];
NSLog(@"reference count is %i",[str retainCount]);
[str release];
NSLog(@"reference count is %i",[str retainCount]);
如果我设置为第一个,我确实看到保留计数为 0 。这是为什么?str
nil