중첩 블록 처리 방식

2554 단어
- (void)pushToWalletView {
    __weak TGGroupCardTaskManager  *wTGGroupCardTaskManager = self;
    [MBProgressHUD showLoading];
    [NRUserRequest checkPayPwdComplete:^(NSError *error, BOOL sucess, BOOL hasCheck) {
      __strong  UIViewController *viewController = self.groupInfoVC;// self.groupInfoVC ,self.groupInfoVC manager weak 
        if (!error) {
            [MBProgressHUD hideHUD];
            if (sucess) {
                if (!([[NRCodeCenter sharedInstance] codeCode] && [[NRCodeCenter sharedInstance] codeR])) {
                    NRVerificationCodeVC *vc = [[NRVerificationCodeVC alloc] init];
                    vc.codetype = IdentifyCodeLoginType;
                    [vc setReturnBlock:^{
                        __strong TGGroupCardTaskManager  *str1TGGroupCardTaskManager = wTGGroupCardTaskManager;// block

                        [str1TGGroupCardTaskManager pushToMyView];
                    }];
                    if (![viewController.navigationController.viewControllers.lastObject isKindOfClass:[NRVerificationCodeVC class]]) {
                        
                        [viewController presentViewController:[[NRNavigationController alloc] initWithRootViewController:vc] animated:YES completion:nil];
                    }
                }else{
                    
                   __strong TGGroupCardTaskManager  *strTGGroupCardTaskManager = wTGGroupCardTaskManager;
                    // block
                    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{//     
                         [strTGGroupCardTaskManager pushToMyView];
                    });
                   
                }
            } else {
                NRVerificationCodeVC *vc = [[NRVerificationCodeVC alloc] init];
                vc.codetype = IdentifyCodeRegisterType;
                [vc setReturnBlock:^{
                      __strong TGGroupCardTaskManager  *strTGGroupCardTaskManager = wTGGroupCardTaskManager;//// block
                    [strTGGroupCardTaskManager pushToMyView];
                }];
                if (![viewController.navigationController.viewControllers.lastObject isKindOfClass:[NRVerificationCodeVC class]]) {
                    [viewController presentViewController:[[NRNavigationController alloc] initWithRootViewController:vc] animated:YES completion:nil];
                }
            }
        } else {
            [MBProgressHUD showError:[error localizedDescription]];
        }
    }];
}

좋은 웹페이지 즐겨찾기