繁体   English   中英

如何阅读Xcode控制台输出?

[英]How to read Xcode console output?

作为Xcode的Java和PHP开发人员,我在处理内存错误时遇到了麻烦。 我有一本书中的示例程序,该程序在启动时因“程序收到信号'SIGABRT'”而崩溃。 我不知道如何使用下面的控制台输出。 我意识到这是某种堆栈跟踪,但是左侧的名称只是应用程序的名称,而不是类或文件。 我不知道“ main + 121”或“ start + 53”是什么意思或在哪里看。 任何指导将不胜感激。

2011-05-11 10:43:23.071 FlowerInfoNavigator[22537:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFDictionary objectForKey:]: method sent to an uninitialized mutable dictionary object'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00dc25a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00f16313 objc_exception_throw + 44
    2   CoreFoundation                      0x00dbf542 -[__NSPlaceholderDictionary objectForKey:] + 194
    3   FlowerInfoNavigator                 0x0000289a -[RootViewController tableView:didSelectRowAtIndexPath:] + 330
    4   UIKit                               0x0008bb68 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
    5   UIKit                               0x00081b05 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
    6   Foundation                          0x0079b79e __NSFireDelayedPerform + 441
    7   CoreFoundation                      0x00da38c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
    8   CoreFoundation                      0x00da4e74 __CFRunLoopDoTimer + 1220
    9   CoreFoundation                      0x00d012c9 __CFRunLoopRun + 1817
    10  CoreFoundation                      0x00d00840 CFRunLoopRunSpecific + 208
    11  CoreFoundation                      0x00d00761 CFRunLoopRunInMode + 97
    12  GraphicsServices                    0x00ffa1c4 GSEventRunModal + 217
    13  GraphicsServices                    0x00ffa289 GSEventRun + 115
    14  UIKit                               0x00022c93 UIApplicationMain + 1160
    15  FlowerInfoNavigator                 0x00001b99 main + 121
    16  FlowerInfoNavigator                 0x00001b15 start + 53
)
terminate called after throwing an instance of 'NSException'
(gdb)

右侧是堆栈中被调用的方法。 我通常只是从我的一种方法中寻找任何东西(尽管这种方法并不总是可行的),然后它将为您提供问题产生的方法调用。 在“ FlowerInfoNavigator”上的调用号3的跟踪中,调用了tableView:didSelectRowAtIndexPath方法tableView:didSelectRowAtIndexPath且在某处导致崩溃的原因。 您应该能够使用调试器和断点将其从那里缩小到希望的范围。 祝好运。

编辑:当我查看您的错误消息时:它的顶部显示了错误。 您尝试从尚未初始化的NSDictionary检索对象,并且从上面开始,它发生在您的didSelectRowAtIndexPath方法中

控制台将不是您唯一看到的地方。 看看您的调试器。 在那边通常有一行加粗。 如果点击该按钮,它将准确显示崩溃发生的位置。

看起来您没有初始化NSDictionary

崩溃是由于nsdictionary尚未初始化,以及如何在崩溃期间进行搜索,请首先查看控制台,以便您了解导致崩溃或异常的原因,以及了解应用程序崩溃的原因,您可以检出调试器。调试器,在应用程序崩溃的地方,特殊行将以粗体显示。

除了您之外,您还可以使用NSZombieEnabled(BOOL)来获取导致应用程序崩溃的原因。有关NSZombieEnabled的更多信息,请参见http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iphone_development/130 -Debugging_Applications / debugging_applications.html

注意:在处理将应用程序提交到Apple Store时,请确保将NSZombieEnabled设置为NO。

希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM