ios - 在 swift 中使用 for 循环创建字典
问题描述
我只想在 for 循环示例代码的帮助下创建一个字典:
var counter: Int = 1;
var pageCountDict = [String:Any]();
for filterCount in counter..<6
{
if let count = "page_\(filterCount)_vtime" as? String
{
pageCountDict = [count: timeInterval_Int];
}
}
print(pageCountDict);
这个打印命令只给我forloop的最后一个值
我只想要这个变量pageCountDict的所有值在一个字典中
解决方案
推荐阅读
- karate - 如何使用示例表为 SOAP 请求传递空值。记录 2-6 正在形成故障 XML 请求
- javascript - 如何在反应钩子中按系列显示图表
- c# - 如何检查委托是否在方法内返回 true?
- r - 分层 Fisher 和 Wilcoxon 检验
- python - 从 docker 中的 git repo 安装 python 库
- typescript - 如何创建一个泛型类型,它是 TypeScript 中其他类型的组合?
- reactjs - 在 create react app 中创建一个捆绑文件
- build - 报错:emmake make 尝试构建libxml2时出错,找不到libxml.so.2
- python - vue js中如何提示分类指定表单
- arrays - 使用 C 对数组进行排序