swift - 如何更新字典中特定索引处的键和值?
问题描述
获取源索引的详细信息并通过存储它来删除这些值
但是如何在目的地或目的地索引处添加存储的数据???
正在使用字典键和值在自定义单元格/行中显示数据
这里我试图将表格视图中的单元格从源移动到目标。
获取源索引和删除的详细信息工作正常,但如何在目标或目标索引添加相同的数据???
这是我的代码:
let indexSource = dic1.index(forKey: (Array(dic1.keys)[sourceIndexPath.row]))
let rearrangedDataDic = dic1[indexSource!]
dic1.remove(at: indexSource!)
let indexDest = dic1.index(forKey: (Array(dic1.keys)[destinationIndexPath.row]))
dic1.updateValue(rearrangedDataDic.value, forKey: rearrangedDataDic.key)
解决方案
推荐阅读
- oracle-sqldeveloper - SQL 开发人员更新 21.2.0.187 键入延迟
- python - nltk.tokenize.TweetTokenizer 正在拆分 $stock 和 $crypto 代码
- c# - 以 Z 方式将元素绑定到 2 个不同的列
- android - BottomNavigationBar 中的 Jetpack Compose 导航问题
- python - 使用 Lambda 函数并在出现键错误的情况下继续
- powerbi - 连接是否使我的 power bi 服务从 excel 源文件导入数据是实时的
- reactjs - 如何处理在 API 调用响应上重新初始化的状态?
- android - 如何在 Android 上访问完整的 ClipboardManager 历史记录?
- java - 如何自动化系统服务?
- r - 如何从 ggplot2::geom_density_2d_filled 获取有关轮廓的信息?