前提・実現したいこと
Text Fieldに入力した文字列を、Buttonを押すことで出力したいのですが、Cannot convert value of type 'UITextField' to specified type 'String'というエラーが出てしまい困っています。
発生している問題・エラーメッセージ
Cannot convert value of type 'UITextField' to specified type 'String'
該当のソースコード
Swift
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField! @IBOutlet weak var label: UILabel! override func viewDidLoad() { super.viewDidLoad() label.text="Hello World" } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBAction func button(_ sender: Any) { let text: String = textField! label.text=text }
}
### 試したこと ネットで調べてみましたが、解決しませんでした。 ### 補足情報(FW/ツールのバージョンなど)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。