我是swift的新手,在Xcode12.3中遇到错误。在它正常工作之前
我的代码是这样的
let dictOption = options[0] as! NSMutableDictionary
btn2.setTitle(dictOption.string(forKey: "optionValue"), for: .normal)但是它显示了错误
Value of type 'NSMutableDictionary' has no member 'string'有没有人遇到过类似的问题。
请帮帮我!
发布于 2021-05-20 16:25:57
替换
dictOption.string(forKey: "optionValue")使用
dictOption.value(forKey: "optionValue")或更多Swifty
guard let dic = options.first as? [String:Any] ,
let value = dic["optionValue"] as? String else { return }
btn2.setTitle(value, for: .normal)https://stackoverflow.com/questions/67616651
复制相似问题