【问题标题】:Rogue Zombie on dealloc of ViewControllerViewController 解除分配上的 Rogue Zombie
【发布时间】: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


【解决方案1】:

我猜你的 TestViewController 有出口和属性。如果这些属性/插座中的任何一个被过度释放,都会导致此错误。确保 [super dealloc] 也是你的 dealloc 方法的最后一行

【讨论】:

  • 谢谢,但你试过吗?除了由 xCode 自动添加的内容外,没有其他任何东西。值得一试,看看是否得到相同的结果。
  • 我试过了,而且正如你所说的那样工作。它只发生在超级僵尸的调试停止中。我不会太担心它。这可能是调试器故障。如果我太担心我可能会在 [super dealloc] 之后添加 self = nil
  • 谢谢西比。至少我知道我不会生气。感谢您的宝贵时间。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-29
  • 1970-01-01
  • 2015-02-15
  • 1970-01-01
  • 2020-11-28
  • 1970-01-01
相关资源
最近更新 更多