ios - AppList 数据源在 -[NSIndexPath row] 中断言失败

标签 ios objective-c theos cydia-substrate

请参阅下面的更新。

我正在编写一个调整并使用 AppList。我正在关注聚光灯并创建一个包含所有已安装应用程序的表格。我正在尝试使用数据源来获取信息(显示标识符等)。问题是如果定义了 dataSource...我收到以下错误:

SpringBoard[1622] <Warning>: *** Assertion failure in -[NSIndexPath row], /SourceCache/UIKit/UIKit-2380.17/UITableViewSupport.m:2680 SpringBoard[1622] <Warning>: ***** AltKeyboard Uncaught Exception: Invalid index path for use with UITableView. Index paths passed to table view must contain exactly two indices specifying the section and row. Please use the category on NSIndexPath in UITableView.h if possible. *****

SpringBoard[1890] <Warning>: ***** AltKeyboard Uncaught Exception: *** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1] ***** SpringBoard[1890] <Error>: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]' *** First throw call stack:

如果未定义数据源并且我使用假数据(测试名称),则表会生成正常。当我打印数据源时,其中只有两项。

IRC 上的瑞安·佩特里奇 (Ryan Petrich) 似乎暗示我所做的一切都完全错误,但此后并没有多大帮助。也许我正在错误地解决这个问题?

代码:http://pastebin.ca/2457626
存储库:https://github.com/twodayslate/ListLauncher

编辑/更新! 数据源给我带来了问题。它没有获取相同数量的应用程序,因此我收到索引错误等。我有 200 多个应用程序,但 dataSource 仅获取 2 个应用程序。
以下代码没有错误,但仅显示 2 项:http://pastebin.ca/2458961

编辑! 我改变了它,所以我只使用 ALApplicationList。我可以获得列出的所有应用程序。但是,当我尝试滚动表格时,它崩溃了。排序和创建列表非常慢,所以我相信这可能是导致问题的原因。我不是 obj-c 的专家,所以我确信有比我正在做的更好的方法。 http://pastebin.ca/2459318

最佳答案

你的问题是双重的。首先,UITableView 期望获得包含行和节的索引路径,而您只为其提供了行。其次,您不能期望未经检查的数组访问 100% 成功,因此边界检查您可能使用的任何访问调用。在代码中的 iVar 赋值中使用一些保留也没有什么坏处,除非您不需要保留对它的引用(但看起来您确实需要)。

关于ios - AppList 数据源在 -[NSIndexPath row] 中断言失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18972962/

相关文章:

ios - 追踪低内存警告的根本原因

ios - dispatch_async 和帧率

ios - 由于自动布局,uiscrollview 不滚动

objective-c - 实现自己的 setter 还是使用 KVO?

ios - 在整个应用程序中设置 UIKeyboardAppearance

makefile - dpkg 错误 : contains ununderstood data member

iOSOpenDev Theos - 如何运行

ios - 带有左右标签的 UITableViewCell。如何让它们正确显示?

objective-c - UITableView 崩溃

xcode - class-dump-z "Fail to map * into memory"问题