我收到來自Crashlytics的崩潰報告,總是在相同的地方,但我無法複製崩潰。報告UITableview崩潰reloadData
它似乎只是iOS 9上的用戶,並且只是偶爾。我不確定這是代碼問題還是其他問題。最後一行提到libdispatch.dylib
缺失,再次,不確定是否相關。
Crashlytics表示碰撞發生在MMDetailTableVC.m
行1407,這是reloadData
行。
下面是報道:
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000001
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x20f0fae2 objc_msgSend + 1
1 CoreFoundation 0x2168b91b -[NSDictionary descriptionWithLocale:indent:] + 310
2 Foundation 0x21e77e2d _NSDescriptionWithLocaleFunc + 60
3 CoreFoundation 0x217091a3 __CFStringAppendFormatCore + 7986
4 CoreFoundation 0x21707255 _CFStringCreateWithFormatAndArgumentsAux2 + 80
5 CoreFoundation 0x2171f559 _CFLogvEx2 + 96
6 CoreFoundation 0x2171f9af _CFLogvEx3 + 118
7 Foundation 0x21f3f4f7 _NSLogv + 126
8 Foundation 0x21e8679d NSLog + 28
9 UIKit 0x259b45fb -[UITableView reloadData] + 1818
10 Simple Meeting Minutes 0x91fff -[MMDetailTableVC saveItemEntry:] (MMDetailTableVC.m:1407)
11 Simple Meeting Minutes 0xa2edf -[MMItemViewController saveButtonAction:] (MMItemViewController.m:526)
12 UIKit 0x25905771 -[UIApplication sendAction:to:from:forEvent:] + 80
13 UIKit 0x25a86c71 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 140
14 UIKit 0x25905771 -[UIApplication sendAction:to:from:forEvent:] + 80
15 UIKit 0x25905701 -[UIControl sendAction:to:forEvent:] + 64
16 UIKit 0x258ed61f -[UIControl _sendActionsForEvents:withEvent:] + 446
17 UIKit 0x258ed74b -[UIControl _sendActionsForEvents:withEvent:] + 746
18 UIKit 0x25905051 -[UIControl touchesEnded:withEvent:] + 616
19 UIKit 0x25904cbf -[UIWindow _sendTouchesForEvent:] + 646
20 UIKit 0x258fd5d7 -[UIWindow sendEvent:] + 642
21 UIKit 0x258ce119 -[UIApplication sendEvent:] + 204
22 UIKit 0x258cc757 _UIApplicationHandleEventQueue + 5134
23 CoreFoundation 0x216f9257 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
24 CoreFoundation 0x216f8e47 __CFRunLoopDoSources0 + 454
25 CoreFoundation 0x216f71af __CFRunLoopRun + 806
26 CoreFoundation 0x21649bb9 CFRunLoopRunSpecific + 516
27 CoreFoundation 0x216499ad CFRunLoopRunInMode + 108
28 GraphicsServices 0x228c3af9 GSEventRunModal + 160
29 UIKit 0x25935fb5 UIApplicationMain + 144
30 Simple Meeting Minutes 0x8c59f main (main.m:16)
31 libdispatch.dylib 0x212fc873 (Missing)
下面是我爲saveItemEntry
的代碼,似乎總是在發生崩潰的地方。
- (void)saveItemEntry:(MMitem *)item{
if (item)
{
NSString *resultStr = [self.meetingModel saveItem:item];
if ([resultStr isEqualToString:@"OK"])
{
// all good so close form and refresh data
[_itemViewController dismissViewControllerAnimated:NO completion:nil];
[self.tableView reloadData];
// or if there is an error result then display message
}
else if ([resultStr isEqualToString:@"DescriptionNotesMissing"])
{
[self showAlert:@"Missing Description or Notes" :@"An Item Description or Notes is required" :0];
[self.itemViewController.itemDescription becomeFirstResponder];
}
// for any other error do nothing
}
}
感謝Ankit,我將該方法作爲第二個視圖控制器MMItemViewController的委託方法調用。第一個VC是包含項目列表的表格VC,第二個VC用於編輯項目。用戶選擇取消或保存以調用第一個控件中的相應方法。我也注意到我正在使用[_itemViewController dismissViewControllerAnimated:No completion:nil]和其他地方我使用[self dismissViewControllerAnimated:No completion:nil]。兩者都能正常工作,但我相信第二種方法更爲正確。你認爲這可能是相關的嗎? – Paul
在使用您建議的代碼時,它希望看到一個右括號。我穿上如下:dispatch_async(dispatch_get_main_queue(),^(void){_itemViewController dismissViewControllerAnimated:NO completion:nil]; [self.tableView reloadData]; });'是否正確?你能解釋一下你的代碼在做什麼嗎?謝謝 – Paul
我只共享未經測試的代碼,可能是括號丟失。 –