我这里有这个代码...为什么Objective-C对象在交易后仍然存在?
#import <Foundation/Foundation.h>
#import "Chip.h"
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Chip *chip = [[Chip alloc] init];
[chip release]; //Chip should be gone
NSLog(@"%@", chip);
[pool drain];
return 0;
}
为什么打印出来后发布的芯片仍然给我描述。在这一点上不应该被删除?
没有。 OP明确指出`setChip`只能分配。 – walkytalky 2011-01-27 17:11:00
释放的内存还没有被覆盖,并且仍然包含相同的字节以进行记录。 – Richard 2011-01-27 17:12:02
@walkytalky:啊,你说得对,我错过了原帖。我觉得他的二传手实施仍在继续。 – Matt 2011-01-27 17:16:45