請參見下面的更新。使用AppList數據源在[NSIndexPath行]中聲明失敗
我正在寫一個調整,並使用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
編輯/更新! dataSource給我的問題。它沒有獲取相同數量的應用程序,因此我得到索引錯誤等。我有超過200個應用程序,但數據源是隻取2
下面的代碼沒有給出錯誤,但只顯示2項:http://pastebin.ca/2458961
編輯! 我改變了它,所以我只使用ALApplicationList。我能夠獲得列出的所有應用程序。但是,當我試圖滾動瀏覽表時,它崩潰了。排序和創建列表非常慢,所以我認爲這可能會導致問題。我不是obj-c的專家,所以我確信有比我更好的方法。 http://pastebin.ca/2459318
[Can not get deleteRowsAtIndexPaths to work](http://stackoverflow.com/questions/8774091/cannot-get-deleterowsatindexpaths-to-work)的可能的重複。這個問題的答案適用於這個問題,因爲異常的根本原因是相同的。 – CodaFi
我從來沒有創建NSIndexPath,所以我認爲這是不同於上述解決方案 – twodayslate
不要那麼確定。 Pastebin鏈接中的第164行似乎對我很有幫助。 – CodaFi