【发布时间】:2013-01-03 11:31:52
【问题描述】:
在 Xcode 中,启动一个新的主从项目。称之为“测试”。
向其中添加一个新的“文件”。使用 XIB 将其设为 UIViewController 文件。称它为 TestViewController。
在 insertNewObject: 方法中修改你的 MasterViewController 代码,这样说:
-(void)insertNewObject:(id)sender
{
TestViewController *initViewController = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
[self.navigationController pushViewController:initViewController animated:YES];
[initViewController release];
}
现在在 TestViewController.m 中添加一个dealloc 方法并简单地调用[super dealloc];
在此处设置断点并运行应用程序。一切都应该运行正常。
但是,如果您启用 Zombie 对象,您可能会在越过 [super dealloc] 时得到一个 *** -[TestViewController class]: message sent to deallocated instance 0x7484f20 error。
你也明白了吗?我在 iOS6.0 模拟器上,并在尝试调试导致我出现此问题的问题时遇到了它。
想法表示赞赏。这是一个iOS错误吗?还是模拟器bug?
为 'clarity' 添加了 TestViewController 代码
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)dealloc
{
// Zombie here???
[super dealloc];
}
【问题讨论】:
-
TestViewController initWithNibName:bundle:里面是什么? -
为
-[TestViewController dealloc]设置断点以查看何时释放。 -
嗨 Nekto。这是代码。这是 xCode 添加的样板,除了 dealloc...(见编辑)
标签: iphone xcode ipad dealloc zombie-process