相关疑难解决方法(0)

无法使用类型为'(String?)'的参数列表调用类型为'Double'的初始值设定项

我有两个问题:

let amount:String? = amountTF.text
Run Code Online (Sandbox Code Playgroud)
  1. amount?.characters.count <= 0

它给出了错误:

Binary operator '<=' cannot be applied to operands of type 'String.CharacterView.IndexDistance?' (aka 'Optional<Int>') and 'In
Run Code Online (Sandbox Code Playgroud)
  1. let am = Double(amount)

它给出了错误:

Cannot invoke initializer for type 'Double' with an argument list of type '(String?)'
Run Code Online (Sandbox Code Playgroud)

我不知道如何解决这个问题.

int xcode ios swift

10
推荐指数
2
解决办法
3万
查看次数

标签 统计

int ×1

ios ×1

swift ×1

xcode ×1