从“双精度"类型转换为无关类型“字符串"始终失败 [英] Cast from 'Double' to unrelated type 'String' always fails
本文介绍了从“双精度"类型转换为无关类型“字符串"始终失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从api响应中获取数据
我正确解码了数据
然后将值分配给tableview
单元格
I'm getting the data from the api response
I decoded the data properly
then I assigned the values to tableview
cell
但是我收到警告
从双精度"类型转换为不相关的字符串"类型始终失败
Cast from 'Double' to unrelated type 'String' always fails
如何解决这个问题,以便可以将double值分配给UILabel并获取结果
how can I solve this , So that I can assign the double value to the UILabel and get my result
我尝试了以下代码
var rate : Double
cell.priceOfVehicleLabel.text = details.rate as? String
推荐答案
您需要
cell.priceOfVehicleLabel.text = "\(details.rate)"
这篇关于从“双精度"类型转换为无关类型“字符串"始终失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文