** – :索引18446744073709551615超出边界

我试图了解崩溃背后的原因。

什么是__NSSingleObjectArrayI ? 我找不到任何关于此的信息。

crashlytics发送的崩溃日志是:

  Fatal Exception: NSRangeException 0 CoreFoundation 0x1836fa1c0 __exceptionPreprocess 1 libobjc.A.dylib 0x18213455c objc_exception_throw 2 CoreFoundation 0x1836eb428 +[__NSSingleObjectArrayI automaticallyNotifiesObserversForKey:] 3 boostApp 0x100070098 -[LocationPromptVc tableView:didSelectRowAtIndexPath:] (LocationPromptVc.m:269) 4 UIKit 0x189683078 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] 5 UIKit 0x189733b34 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] 6 UIKit 0x1897e6d5c _runAfterCACommitDeferredBlocks 7 UIKit 0x1897d8b10 _cleanUpAfterCAFlushAndRunDeferredBlocks 8 UIKit 0x189547854 _afterCACommitHandler 9 CoreFoundation 0x1836a77dc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ 10 CoreFoundation 0x1836a540c __CFRunLoopDoObservers 11 CoreFoundation 0x1836a589c __CFRunLoopRun 12 CoreFoundation 0x1835d4048 CFRunLoopRunSpecific 13 GraphicsServices 0x18505a198 GSEventRunModal 14 UIKit 0x1895c02fc -[UIApplication _run] 15 UIKit 0x1895bb034 UIApplicationMain 16 boostApp 0x1000bbc24 main (main.m:14) 17 libdispatch.dylib 0x1825b85b8 (Missing) 

崩溃发生在以下方法中:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ //NSArray //NSArray both are strong,nonatomic self.selectedLocation = self.filteredLocations[indexPath.row]; [self.tableView reloadData]; [self.searchField resignFirstResponder]; } 

//数据源方法

 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.filteredLocations.count; } 

在iOS10上发生了74%的崩溃事件。 在过去的90天里,我遇到了31次崩溃。

为什么didSelectRow方法指向错误的索引18446744073709551615?

这次崩溃是非常罕见的,我无法重现它。 关于调试的任何想法?

表格视图很简单.IT在导航栏上有一个搜索字段,基于搜索字段文本,我过滤位置并填充表格视图。一旦用户选择任何一行,我就会在不同的VC上显示位置数据。

试试这段代码..愿这段代码有所帮助。 在我的应用程序中,我也遇到了与collectionView相同的崩溃,而且非常罕见。 它纯粹是indexOutOfBounds问题。 我不知道我的collectionView如何显示比数据源计数更多的项目。 但条件检查有助于我,现在我的应用程序没有崩溃

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ //NSArray //NSArray both are strong,nonatomic if (self.filteredLocations.count > indexPath.row && indexPath.row >= 0) { self.selectedLocation = self.filteredLocations[indexPath.row]; [self.tableView reloadData]; [self.searchField resignFirstResponder]; } }