Objective-C警告 - 我错过了什么或出了什么问题?

时间:2011-10-10 16:04:03

标签: objective-c debugging warnings

我是编程新手,现在我正在编写一个包含6个视图的应用程序。 我的程序开始不是真的,我只看到背景 - default.png - 然后prpgramm崩溃,但我看到默认图像。 另外,我在理解我收到的警告时遇到了问题,它就像一种新语言。 如果你知道一本书或一个页面如何解码这个警告,它也会非常有用

2011-10-10 17:22:16.249 TestTest[2642:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "TestTestViewController" nib but the view outlet was not set.'

(
0   CoreFoundation                      0x00ec25a9 __exceptionPreprocess + 185
1   libobjc.A.dylib                     0x01016313 objc_exception_throw + 44
2   CoreFoundation                      0x00e7aef8 +[NSExceptionraise:format:arguments:] + 136
3   CoreFoundation                      0x00e7ae6a +[NSException raise:format:] + 58
4   UIKit                               0x0036b709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5   UIKit                               0x00369134 -[UIViewController loadView] + 120
6   UIKit                               0x0036900e -[UIViewController view] + 56
7   UIKit                               0x002dcd42 -[UIWindow addRootViewControllerViewIfPossible] + 51
8   UIKit                               0x002dc22d -[UIWindow _setHidden:forced:] + 303
9   UIKit                               0x002dc01d -[UIWindow _orderFrontWithoutMakingKey] + 50
10  UIKit                               0x002dacd1 -[UIWindow makeKeyAndVisible] + 39
11  TestTest                            0x000026be -[TestTestAppDelegate application:didFinishLaunchingWithOptions:] + 135
12  UIKit                               0x002b9c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
13  UIKit                               0x002bbd88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
14  UIKit                               0x002c6617 -[UIApplication handleEvent:withNewEvent:] + 1533
15  UIKit                               0x002beabf -[UIApplication sendEvent:] + 71
16  UIKit                               0x002c3f2e _UIApplicationHandleEvent + 7576
17  GraphicsServices                    0x0181a992 PurpleEventCallback + 1550
18  CoreFoundation                      0x00ea3944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
19  CoreFoundation                      0x00e03cf7 __CFRunLoopDoSource1 + 215
20  CoreFoundation                      0x00e00f83 __CFRunLoopRun + 979
21  CoreFoundation                      0x00e00840 CFRunLoopRunSpecific + 208
22  CoreFoundation                      0x00e00761 CFRunLoopRunInMode + 97
23  UIKit                               0x002bb7d2 -[UIApplication _run] + 623
24  UIKit                               0x002c7c93 UIApplicationMain + 1160
25  TestTest                            0x00002614 main + 102
26  TestTest                            0x000025a5 start + 53
27  ???                                 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.
kill
quit

The Debugger has exited with status 0.(gdb) 

提前谢谢

3 个答案:

答案 0 :(得分:1)

查看崩溃报告的第一行,崩溃的原因非常明显:

加载了“TestTestViewController”笔尖,但未设置视图插座。

答案 1 :(得分:1)

您已在NIB中创建了一个视图控制器,但您未能为其提供视图。您应该通过将视图放入NIB并从视图控制器到视图进行控制 - 单击,然后从显示的弹出窗口中选择视图插座 - 即在界面设计器中连接内容的常规方式。

您看到的错误是由UIViewController故意引发的异常,因为它不知道如何在没有视图的情况下继续。下面的东西是堆栈跟踪;如果问题出在您自己的代码中,您可以使用它来查看调用模式使您进入无效状态。因为它是在一堆内部的东西,逻辑结构被记录,但内部实现是私人的,你应该忽略它。

答案 2 :(得分:0)

返回您正在使用的任何文本,了解如何创建视图控制器和XIB文件,并找出错过的步骤。