gpt4 book ai didi

swift - 插入字典 int 和 string 不起作用(swift4)

转载 作者:行者123 更新时间:2023-11-30 12:06:44 24 4
gpt4 key购买 nike

我正在尝试将另一个字典条目插入到一个不起作用的结构中。我试图同时使用 int 和 String 作为字典。

 @IBAction func move(_ sender: Any) {

Bad2.addx.insert(0:"dan", at: 0)


}
struct Bad2 {
static var addx: [Int:String] = [1:"joe", 2:"fen"]

}

最佳答案

这不是向字典添加键/值的方式。您需要:

Bad2.addx[0] = "dan"

关于swift - 插入字典 int 和 string 不起作用(swift4),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46593726/

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