Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图在标签上显示一个双数字。但它显示为可选。我无法使用“!”打开它 因为有些数据是零。
如何使“可选(...)”文本不显示?
这是它的外观:
let row = elementArray[indexPath.row] mPoint.text = String(row.meltPoint) //Optional(2070.0)
用于if let解开可选值:
if let
let row = elementArray[indexPath.row] if let myNumber = row.meltPoint { mPoint.text = "\(myNumber)" } else { mPoint.text = "N/A" }