2015-03-13 50 views
0

我是Xcode和Objective-C的新手。与Android Java异常不同,我没有找到发生异常的确切行号,但可以从崩溃日志中获知函数名称。以下是崩溃日志:Xcode中的异常的确切代码

2014-07-28 17:44:53.814 ExampleApp[82720:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil' 
*** First throw call stack: 
(
0 CoreFoundation      0x034b25e4 __exceptionPreprocess + 180 
1 libobjc.A.dylib      0x028bc8b6 objc_exception_throw + 44 
2 CoreFoundation      0x03464bcc -[__NSArrayM insertObject:atIndex:] + 844 
3 CoreFoundation      0x03464870 -[__NSArrayM addObject:] + 64 
4 ExampleApp       0x0017f99e +[ReportGenerator prepareReportList:] + 5486 
5 ExampleApp       0x0017db99 +[ReportGenerator generateReportContent:viewController:] + 73 
6 ExampleApp       0x0017b682 +[ReportGenerator generateReport:viewController:style:] + 322 
7 ExampleApp       0x000a68fd -[ReportsViewController showReport] + 189 
8 libobjc.A.dylib      0x028ce81f -[NSObject performSelector:withObject:] + 70 
9 Foundation       0x01fa29d8 __NSThreadPerformPerform + 285 
10 CoreFoundation      0x0343b83f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 
11 CoreFoundation      0x0343b1cb __CFRunLoopDoSources0 + 235 
12 CoreFoundation      0x0345829e __CFRunLoopRun + 910 
13 CoreFoundation      0x03457ac3 CFRunLoopRunSpecific + 467 
14 CoreFoundation      0x034578db CFRunLoopRunInMode + 123 
15 GraphicsServices     0x046949e2 GSEventRunModal + 192 
16 GraphicsServices     0x04694809 GSEventRun + 104 
17 UIKit        0x010bbd3b UIApplicationMain + 1225 
18 ExampleApp       0x0011679d main + 125 
19 libdyld.dylib      0x0300a701 start + 1)libc++abi.dylib: terminating with uncaught exception of type NSException 

回答

1

您可以添加一个断点以停止所有异常。

Apple Docs

  1. 在断点导航器的左下角,点击添加按钮。

  2. 选择添加异常断点。

  3. 在异常弹出菜单中,选择您要停止执行的异常类型:

    • 所有。停止所有例外。 Objective-C。
    • Objective-C。停止Objective-C异常。 C++。停止使用C++异常。
    • 要停止特定的C++异常,请指定异常名称。
  4. 选择希望程序执行停止的异常处理过程的阶段。

  5. 单击完成。

+0

我同意,但如果我从测试人员那里得到一个崩溃报告,并且我想查找崩溃发生的行号 - 我可以知道吗?崩溃报告中的每行都有一些数字(请参阅上面粘贴的崩溃日志) - 他们提供了什么信息? – 2015-03-13 09:35:08

0

碰撞发生在您的+[ReportGenerator prepareReportList:]方法中。特别是,当试图将一个对象添加到数组。

只,对象为零。这就是为什么日志始于对象不能为零

(注意:当你从Java异常的世界,不要错误地认为ObjC例外被设计成被捕获并从恢复的错误,他们都没有)