gpt4 book ai didi

Swift 2迁移错误: "Type of expression is ambiguous without more context "

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

运行 Swift 2 迁移后,我收到此错误:

Type of expression is ambiguous without more context

对于这一行:

 var interestItems = [String, NSNumber, Bool]()

最佳答案

在 Swift 1.2 中,编译器自动从 [String, NSNumber, Bool] 推断类型 [(String, NSNumber, Bool)] (元组数组)。

从 Swift 2 开始就不再这样了,迁移后你必须显式声明元组:

var interestItems = [(String, NSNumber, Bool)]()

关于Swift 2迁移错误: "Type of expression is ambiguous without more context ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32766190/

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