Cannot invoke initializer for type 'Double' with an argument list of type '(String?)'

后端 未结 3 2014
轻奢々
轻奢々 2020-12-06 10:58

I have two issues:

let amount:String? = amountTF.text
  1. amount?.characters.count <= 0

It\'s giving error

3条回答
  •  执念已碎
    2020-12-06 11:43

    Another reason for the error is amount it should not be null

    let am = Double(amount!)
    

    with check contol

    if amount != nil {
       let am = Double(amount!)
    }
    

提交回复
热议问题