gpt4 book ai didi

Swift 字典数组

转载 作者:行者123 更新时间:2023-11-30 14:17:18 25 4
gpt4 key购买 nike

我正在使用 Swift 1.2,并尝试获取来自 Swift 早期版本的声明的正确语法:

 var dataSource: Dictionary<String, String> [][] = [[],[]]

我得到的错误是:

Array types are now written with the brackets around the element type.

我只是不知道如何纠正它。

最佳答案

从那时起语法发生了变化。正如您的错误所示:

Array types are now written with the brackets around the element type.

所以代替 Dictionary<String, String>[][]将类型括在括号中,例如 [[Dictionary<String, String>]]或使用简写语法:[[[String: String]]] :

var dataSource: [[[String: String]]] = [[],[]]

关于Swift 字典数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30965035/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com