运行应用程序时出错:未捕获的异常' NSInternalInconsistencyException'

时间:2015-11-16 08:43:43

标签: ios

我是iOS编程新手,有人刚刚将iOS项目传递给我,我正试图运行它。我的第一个问题是GoogleMaps缺少文件但我下载了GoogleMaps框架并在项目中重新导入它。我的下一个问题是:Terminating app due to uncaught exception 'NSInternalInconsistencyException'

enter image description here

这是输出:

2015-11-16 16:24:43.834 appname[870:39308] -> connection established!
2015-11-16 16:24:43.884 appname[870:39308] *** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.29.5/UIApplication.m:3299
2015-11-16 16:24:43.899 appname[870:39308] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000113c46f45 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x00000001136c0deb objc_exception_throw + 48
    2   CoreFoundation                      0x0000000113c46daa +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x000000011330d5ee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
    4   UIKit                               0x0000000111d47f15 -[UIApplication _runWithMainScene:transitionContext:completion:] + 3112
    5   UIKit                               0x0000000111d44ba3 -[UIApplication workspaceDidEndTransaction:] + 188
    6   FrontBoardServices                  0x0000000118437784 -[FBSSerialQueue _performNext] + 192
    7   FrontBoardServices                  0x0000000118437af2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
    8   CoreFoundation                      0x0000000113b73011 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    9   CoreFoundation                      0x0000000113b68f3c __CFRunLoopDoSources0 + 556
    10  CoreFoundation                      0x0000000113b683f3 __CFRunLoopRun + 867
    11  CoreFoundation                      0x0000000113b67e08 CFRunLoopRunSpecific + 488
    12  UIKit                               0x0000000111d444f5 -[UIApplication _run] + 402
    13  UIKit                               0x0000000111d4930d UIApplicationMain + 171
    14  appname                             0x000000010ff42213 main + 99
    15  libdyld.dylib                       0x000000011412a92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

2 个答案:

答案 0 :(得分:0)

例外描述为Application windows are expected to have a root view controller at the end of application launch
因此,将任何视图控制器设置为intreface bulder中的根或AppDelegate中的- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法

答案 1 :(得分:0)

AppDelegate.m中,在didFinishLaunchingWithOptions:方法下,将根视图控制器设置如下: -

UIViewController *launchViewController = [UIViewController instantiateViewControllerWithIdentifier:@"LaunchViewController" fromStoryboard:@"Main"];

self.window=[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
[self.window setRootViewController:launchViewController];
[self.window makeKeyAndVisible];

注意: - 您的故事板中初始视图控制器的标识符可能有所不同。因此,请将@"LaunchViewController"替换为您的标识符值。