Swift 如何将字符串分配给 UITextField?

Swift 如何将字符串分配给 UITextField?

问题描述:

@IBOutlet weak var resultProcessed: UITextField!
var str:String = "Mike is here"
resultProcessed = str

给出错误:无法将String"类型的值分配给UITestField!"类型的值

gives error: Cannot assign a value of type 'String' to a value of type 'UITestField!'

resultProcessed.text = str

您需要将其分配给 text 属性.

You need to assign it to the text property.