OK、これで私の問題は解決したようです。誰かがよりエレガントなソリューションを知っている場合は、私に知らせてください。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([self.tableView cellForRowAtIndexPath:indexPath].accessoryType == UITableViewCellAccessoryCheckmark) {
[self.tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone;
[self.tableView cellForRowAtIndexPath:indexPath].textLabel.textColor = [UIColor colorWithRed:0.0 / 255 green:0.0 / 255 blue:0.0 / 255 alpha:1];
[selectedSources removeObject:[NSNumber numberWithInt:indexPath.row]];
} else {
[self.tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
[self.tableView cellForRowAtIndexPath:indexPath].textLabel.textColor = [UIColor colorWithRed:72.0 / 255 green:104.0 / 255 blue:152.0 / 255 alpha:1];
[selectedSources addObject:[NSNumber numberWithInt:indexPath.row]];
}
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
selectedSources
これを JSON エンコードしてサーバーに送信します。インデックス パスに基づいて、サーバー側でチェックされている/チェックされていないテーブル ビュー セルを特定できます。
ありがとう、アンナ!