我编写了以下代码:
NSString *string = [[NSString alloc] initWithFormat:@"test"];
[string release];
NSLog(@"string lenght = %d", [string length]);
//Why I don't get EXC_BAD_ACCESS at this point?
我应该,它应该被释放。上次发布后,retainCount 应该是 0,为什么不是呢?
PS 我正在使用最新的 XCode。
更新:
NSString *string = [[NSString alloc] initWithFormat:@"test"];
NSLog(@"retainCount before = %d", [string retainCount]);// => 1
[string release];
NSLog(@"retainCount after = %d", [string retainCount]);// => 1 Why!?