如何从日志中找出错误

时间:2014-07-23 07:30:32

标签: ios objective-c

我的项目崩溃并指向main.m文件

中的以下行
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

并显示登录控制台,因为我无法找到文件或行号来修复错误。

2014-07-23 13:24:08.564 Test Project[11312:707] Starting app
2014-07-23 13:24:08.577 Test Project[11312:707] Application windows are expected to have a root view controller at the end of application launch
2014-07-23 13:24:08.969 Test Project[11312:707] get pin pass
2014-07-23 13:24:08.973 Test Project[11312:707] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x36c5f88f 0x33076259 0x36bb723d 0x987e7 0x32892933 0x36c33a33 0x36c33699 0x36c3226f 0x36bb54a5 0x36bb536d 0x34d7c439 0x34e5ecd5 0x93679 0x935c8)
terminate called throwing an exception(lldb) 

有一个点*** -[__NSArrayI objectAtIndex:]:,但在所有文件中使用的越来越多。

如何修复此错误。

2 个答案:

答案 0 :(得分:0)

您的日志打印“get pin pass”,因此在项目中找到此文本,并在空数组上查看您在哪里调用[NSArray objectAtIndex:]。该数组中没有任何对象。这样做是为了避免崩溃

if(array.count > index){
  [NSArray objectAtIndex:index];
}

希望这有帮助

答案 1 :(得分:0)

添加一个异常断点,它将在导致异常的编码行上停止。

说明在这里:https://developer.apple.com/library/ios/recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html

相关问题