根据对Value of type 'String' does not conform to expected dictionary value type 'AnyObject'问题的回答,导入 Foundation 应隐式将 Swift结构桥接到,因此它可以在字典中使用。但我在 Xcode 8/Swift 3 中没有看到这种行为:String
NSString
[String : AnyObject]
import Foundation
let dict: [String : AnyObject] = ["hello" : "world"] // Value of type 'String' does not conform to expected dictionary value type 'AnyObject'
Swift 字符串是否不再隐式桥接到NSString
? 我唯一的选择是将我的String
值转换为AnyObject
orNSString
还是使用[String : Any]
字典类型?