indexPaths に依存せずに tableView の行をチェックしようとしています。これは私が以前に尋ねた質問に似ていますが、これは実際よりも簡単なはずです。
tableView のデータ ソースである静的な値の配列があり、それを fullArray と呼びます。行が選択されると、その値が別の配列に配置されます - それを partialArray と呼びましょう。indexPaths を使用してこれを行う前は、partialArray を次のように反復処理していました。
for(NSIndexPath * elem in [[SharedAppData sharedStore] selectedItemRows]) {
if ([indexPath compare:elem] == NSOrderedSame) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}
魅力のように機能します。ただし、部分配列の値を使用してこれを実行しようとしていて、問題が発生しています。
sudo コードの cellForRowAtIndexPath メソッドでどのように機能するかを次に示します。
fullArray 内のすべての文字列について、partialArray 内にある場合は、その indexPath を取得して確認します。
私がまとめ始めたコード:
for(NSString *string in fullArray) {
if (partialArray containsObject:string) {
//Need help here. Get the index of the string from full array
fullArray indexOfObject:string];
//And check it.
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}
それほど難しくないように思えますが、頭を包むことはできません。