gpt4 book ai didi

ios - ** -[__NSSingleObjectArrayI objectAtIndex :]: index 18446744073709551615 beyond bounds [0 .。 0]

转载 作者:行者123 更新时间:2023-12-01 19:59:23 26 4
gpt4 key购买 nike

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

什么是__NSSingleObjectArrayI ?我找不到这方面的任何信息。

crashlytics发送的crashlog是:

 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;
}

74% 的崩溃发生在 iOS10 上。在过去的 90 天内,我发生了 31 次崩溃。

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

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

表格 View 很简单。它在导航栏上有一个搜索字段,根据搜索字段文本,我过滤位置并填充表格 View 。一旦用户选择任何行,我就会在不同的 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];
}
}

关于ios - ** -[__NSSingleObjectArrayI objectAtIndex :]: index 18446744073709551615 beyond bounds [0 .。 0],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40663384/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com