【发布时间】:2019-08-11 13:43:49
【问题描述】:
我遇到了这个没有被捕获的异常,即使是在处理异常(@try{}@catch{}),这可能很容易,但我现在看不到。异常说'试图弹出一个不存在的视图控制器。'我相信一个参数正在传递nil,但我没有看到它:
-(void) theProblemMethod
{
dispatch_async(dispatch_get_main_queue(), ^{
@try {
[[self topViewController] dismissViewControllerAnimated:YES completion: ^{
UIViewController * rootViewControler = nil;
if ((rootViewControler = (UIViewController *) [UIApplication sharedApplication].keyWindow.rootViewController))
{
if([self topViewController])
[(UINavigationController *)[self topViewController].navigationController popToViewController:rootViewControler animated:YES];
if ((rootViewControler = (UIViewController *) [[[[UIApplication sharedApplication] delegate] window] rootViewController].presentedViewController)) {
[rootViewControler dismissViewControllerAnimated:YES completion:
^{
//do something here
}];
}
}
}];
} @catch (NSException *exception) {
NSLog(@"There is a problem at [myClass theProblemMethod] Exception: %@, reason: %@", [exception name], [exception reason]);
} @finally {}
});
}
有人发现问题了吗?
【问题讨论】:
标签: ios objective-c xcode cocoa-touch uikit