1

我正在尝试使用工具来发现为什么我的视图控制器在从导航控制器弹出时不调用 dealloc。在查看分配时,我发现当我弹出视图控制器时,它的 RefCt 保持为 2。我尝试查看所有的 retain<->release 消息,我确实发现了一组似乎不正常的分配。其中有 30 条消息,其中 16 条保留和 14 条释放。这是我的问题吗?这些电话甚至在做什么?我假设我将自己保留在某个街区的某个地方..?

Retain  __copy_helper_block_335
Retain  __copy_helper_block_361
Retain  __copy_helper_block_391
Retain  __copy_helper_block_387
Retain  __copy_helper_block_91
Retain  __copy_helper_block_84
Retain  __copy_helper_block_1797
Retain  __copy_helper_block_2139
Retain  __copy_helper_block_2143
Retain  __copy_helper_block_1647
Retain  __copy_helper_block_2139
Retain  __copy_helper_block_2143
Retain  __copy_helper_block_1678
Retain  __copy_helper_block_2139
Retain  __copy_helper_block_2143
Retain  __copy_helper_block_57
Release __destroy_helper_block_392
Release __destroy_helper_block_336
Release __destroy_helper_block_388
Release __destroy_helper_block_92
Release __destroy_helper_block_85
Release __destroy_helper_block_2140
Release __destroy_helper_block_2144
Release __destroy_helper_block_1648
Release __destroy_helper_block_2140
Release __destroy_helper_block_2144
Release __destroy_helper_block_1679
Release __destroy_helper_block_2140
Release __destroy_helper_block_2144
Release __destroy_helper_block_58

我已经阅读了许多其他关于视图控制器不调用 dealloc 的问题,但仍然无法将我的 RefCt 设置为 0。确保我的所有代表都很弱,并且在所有块中都受到冲击,以确保我没有将 self 保留在块中. 但是,在某些地方我使用 self 而不是 __weak(例如 [GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite))。我需要在这里使用weakSelf吗?

- (void) setupInvitationHandler {
    [GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite) {

        ( ... )

        GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite];
        mmvc.matchmakerDelegate = [self.navigationController.viewControllers objectAtIndex:0];
        [self presentViewController:mmvc animated:YES completion:^{
            [self.navigationController popToRootViewControllerAnimated:NO];
        }];
    }];
}
4

0 回答 0