【发布时间】:2013-06-21 05:53:26
【问题描述】:
在以下经过 ARC 处理并在 Mac OS X 10.8.4 上运行 64 位的代码中,为什么 MyObj 的实例在程序终止之前没有被释放?
#import <Foundation/Foundation.h>
@interface MyObj : NSObject
@end
@implementation MyObj
- (void)dealloc
{
NSLog(@"MyObj dealloc'd %p", self);
}
@end
int main(int argc, const char * argv[])
{
MyObj* obj1 = [[MyObj alloc] init];
__weak MyObj* weakObj1 = obj1;
NSLog(@"Use it: %p\n", weakObj1);
// Why isn't MyObj deallocated here?
return 0;
}
【问题讨论】:
标签: objective-c