UITableView
字幕セル用に構成された があります。にセルを追加すると、TableView
2 つの配列ができます。1 つはサブタイトル用で、もう 1 つはメイン ラベル用です。またNSMutableDictionary
、セルをテーブルに追加すると、オブジェクトとキーが記録されるようにします。UITableView
私の問題は、このメソッドを使用してセルを削除したいときです:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[myArray removeObjectAtIndex:indexPath.row];
[numberArray removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}
これは、関連付けられた配列からオブジェクトを削除するのに最適ですが、作成したオブジェクトからも削除したいと考えていますMutableDictionary
。私が配列で使用したものと同様のものを使用すると思いました。
[myArray removeObjectAtIndex:indexPath.row];
でも使えない
[myDictionary removeObjectForKey:indexPath.row];
私がこれをどのように書くか知っている人はいますか?