【问题标题】:Help using NSZombieEnabled帮助使用 NSZombieEnabled
【发布时间】:2011-07-28 22:02:30
【问题描述】:

我正在尝试调试一些代码。我运行了静态分析器,并认为我修复了内存泄漏,现在当我在两个选项卡之间切换时出现错误。这是我在第二个选项卡和第一个选项卡之间切换时的代码:

        if (_sortButton != nil) {
            self.SortButton = nil;
            NSMutableArray *barItems = [[self.MainToolbar items] mutableCopy];
            [barItems removeObjectAtIndex:0];
            [self.MainToolbar setItems:barItems]; // bad access here
            [barItems release];
        }

我不断在 self.MainToolbar setItems 行上获得 EXC_BAD_ACCESS。我将 NSZombieEnabled 添加为环境变量,在那个错误的访问行设置了一个断点,但是当我在断点之后单步执行、在断点之后点击继续等时,我没有得到任何打印到控制台的信息。我使用正确吗?谢谢。

【问题讨论】:

    标签: iphone debugging nszombie


    【解决方案1】:

    比 NSZombieEnabled 更容易使用,就是在运行并选择 NSZombie 工具时使用Profile

    这需要 XCode4。

    【讨论】:

      【解决方案2】:

      请尝试在 NSArray 的对象列表末尾添加一个 ,nil。

      [self.MainToolbar setItems:barItems,nil]
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多