Swift初始化对象时报参数类型错误,如下:
Argument type 'Double' expected to be an instance of a class or class-constrained type
Argument type 'String' expected to be an instance of a class or class-constrained type
Cannot convert value of type 'String' to expected dictionary value type 'Double'

解决方法为对象参数
中[String: AnyObject] 修改为[String: Any]。
本文解决了Swift中初始化对象时遇到的参数类型错误问题。具体错误包括预期类实例但传入了Double或String类型,以及无法将String类型转换为期望的Dictionary值类型Double。解决方案是将参数类型从[String:AnyObject]更改为[String:Any]。

1768

被折叠的 条评论
为什么被折叠?



