0

サードパーティのライブラリを使用していて、コードでメソッドを呼び出しているときにランダムにクラッシュに直面しています。

クラッシュログには、認識されないセレクター viewControllers が に送信されたことが示されています。

クラッシュログ:キャッチされていない例外 'NSInvalidArgumentException' が原因でアプリを終了しています。理由: '-[ThirdPartyController viewControllers]: 認識されないセレクターがインスタンス 0x1e959bc0 に送信されました'

ただし、以下に示すように、このメソッドを呼び出す前にすべての安全な処理を行っています。何が間違っている可能性があります。

+ (UINavigationController *)currentNavigationController:(UINavigationController *)iPreviousNavigationController {
 UINavigationController *aCurrentNavigationController = iPreviousNavigationController;
 UINavigationController *aChildNavigationController = (UINavigationController *)[iPreviousNavigationController modalViewController];

 if (aChildNavigationController) {
aCurrentNavigationController = [self currentNavigationController:aChildNavigationController];
 } 

 return aCurrentNavigationController;

}

+ (UIViewController *)currentViewController:(UINavigationController *)iPreviousNavigationController {
    UINavigationController *aCurrentNavigationController = [self currentNavigationController:iPreviousNavigationController];

    if (!aCurrentNavigationController || ![aCurrentNavigationController respondsToSelector:@selector(viewControllers)]) {
    aCurrentNavigationController = [self applicationDelegate].navigationController;
    }

    UIViewController *aCurrentViewController;

    if ([aCurrentNavigationController respondsToSelector:@selector(viewControllers)]) {
         aCurrentViewController = [aCurrentNavigationController.viewControllers lastObject];
    }

    return aCurrentViewController;
}
4

0 に答える 0