weakSelf being deallocated before block

Viewed 221

So somehow my weakSelf variable is being deallocated before my block has a chance to execute. This only happens in one specific scenario, the other times I hit this block it works fine. Here's what my code looks like:

__weak typeof(self) weakSelf = self;
DBTEligibleAccountFetcher *accountFetcher = [[DBTEligibleAccountFetcher alloc] init];
NSArray *eligibleDepositAccounts = [accountFetcher fetchDepositEligibleAccounts];
if(eligibleDepositAccounts.count == 1) {
    DBTDepositAmountLimitsHandler *limitChecker = [[DBTDepositAmountLimitsHandler alloc] init];
    [limitChecker handleRequest:self.navigationController bankAccount:eligibleDepositAccounts.firstObject completionBlock:^(DBDepositCheckAccountLimits *limitDetails) {
        containerController.limitDetails = limitDetails;
        [weakSelf.navigationController handleNewRootPush:containerController withCompletion:completionBlock animated:YES];
    }];
} else {
    [self.navigationController handleNewRootPush:containerController withCompletion:completionBlock animated:YES];
}

By the time it gets to the weakSelf.navigationController... line, weakSelf is nil. I'm not sure how to even debug this or how the variable could get deallocated before it is even used.

Does anyone know any scenarios that could be going on right now? Or any tips on how I might go about debugging this issue?

1 Answers
Related