我這裏有這個代碼...爲什麼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