簡體   English   中英

如何從日志中找出錯誤

[英]How to figure out error from log

我的項目崩潰了,並指向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:]:但在所有文件中使用的點越來越多。

如何修復此錯誤。

您的日志會打印“獲取密碼”,因此請在項目中找到此文本,然后查看在空數組上調用[NSArray objectAtIndex:]的位置。 數組中沒有任何對象。 這樣做以避免崩潰

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

希望這可以幫助

添加異常斷點,該斷點將在導致異常的編碼行上停止。

指示在這里: https : //developer.apple.com/library/ios/recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM