ios - Xcode 中异常的精确行

标签 ios objective-c xcode

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

    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

最佳答案

您可以添加断点以在所有异常时停止。

来自 Apple Docs

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

  2. 选择添加异常断点。

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

    • 全部。停止所有异常。
    • Objective-C 。在 Objective-C 异常时停止。 C++。遇到 C++ 异常时停止。
    • 要停止特定的 C++ 异常,请指定异常名称。
  4. 选择您希望程序停止执行的异常处理过程的阶段。

  5. 点击完成。

关于ios - Xcode 中异常的精确行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29026417/

相关文章:

iphone - 在 IOS 中集成 xPDF? (可行性检查)

ios - Siri 快捷方式 : call API as from the containing App

ios - bloc.io : failing XTCAssertTest for unknown reasons; previously successful in mock app

iphone - MFMessageComposeViewController:如何限制以蜂窝消息而不是 iMessage 的形式发送消息

ios - 使用 swift 5 请求 AlamoFire url

swift - 如何使用 segue "present modally"维护导航?

ios - 新项目的 SwiftUI 2.0 CoreData 问题 - 'Cannot find type ' Item' in scope'

ios - 无法将数据设置为 prepareForSegue 中的数组

objective-c - 如何传递 JSON 请求

ios - swift:我可以拥有一个实际上是引用的属性吗?