【问题标题】:Can't find abandoned memory找不到废弃的记忆
【发布时间】:2012-03-13 07:36:16
【问题描述】:

AgentDashboardNavigationController 生存!

我继续执行相同的过程,我的 tabBarController 中的 agentDashboardNavigationController VC 被一个编辑界面 VC 替换。

完成后,编辑界面将替换为新的 agentDashboardNavigationController。

由于某种原因,活跃的 agentDashboardNavigationController 对象的数量不断增加。

基本上,我通过替换视图控制器的可变副本中的对象来来回翻转该选项卡中的内容。

agentDashboardNavigationController 被换入:

NSMutableArray *newViewControllers = [self.mainTabBarController.viewControllers mutableCopy];
AgentDashboardNavigationController *agentDashboardNavigationController = [[AgentDashboardNavigationController alloc] init];
// cycle through until we find the agentcontroller and remove it
// for now that's the only controller that gets removed so we break
NSUInteger index = [newViewControllers indexOfObjectPassingTest: ^ BOOL (id obj, NSUInteger idx, BOOL *stop) {
    return [[obj tabBarItem].title isEqualToString:@"Guest Card"];
}];

[newViewControllers replaceObjectAtIndex:index withObject:agentDashboardNavigationController];
[self.mainTabBarController setViewControllers:newViewControllers animated:NO];

[newViewControllers release];

[agentDashboardNavigationController release];

它被换掉了:

UISplitViewController *splitVC = self.guestCardManagementController.splitViewController;

// remove agentTab
NSMutableArray *newViewControllers = [self.mainTabBarController.viewControllers mutableCopy];

// cycle through until we find the agentcontroller and remove it
NSUInteger index = [newViewControllers indexOfObjectPassingTest: ^ BOOL (id obj, NSUInteger idx, BOOL *stop) {
    return [obj class] == [AgentDashboardNavigationController class];
}];
[newViewControllers replaceObjectAtIndex:index withObject:splitVC];
[self.mainTabBarController setViewControllers:newViewControllers animated:NO];
[newViewControllers release];

【问题讨论】:

    标签: objective-c ios memory memory-management


    【解决方案1】:

    从头开始。问题是保留周期。一旦我意识到我应该勾选“记录引用计数”位,我可以看到它的孩子正在保留它!

    我的第一个。伙计,解决这些问题很痛苦。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-30
      • 1970-01-01
      • 2013-05-19
      • 1970-01-01
      • 2013-05-04
      相关资源
      最近更新 更多