前提・実現したいこと
テキストフィールド内のテキストの入力がなかった場合にアラートを表示させたい。
アラート機能を実装中に以下のエラーメッセージが発生しました。
発生している問題・エラーメッセージ
Expected '{' in body of function declaration
該当のソースコード
【使用言語swif】
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var firstTextField: UITextField!
@IBOutlet weak var SecondTextField: UITextField!
@IBOutlet weak var culcularButton: UIButton!
@IBOutlet weak var segmentedControll: UISegmentedControl!
@IBOutlet weak var resultLabel: UILabel!
@IBAction func culcularButton(_ sender: UIButton) {
if firstTextField.text?.count == 0 {
func showAller()
print("数字が表示されてないよ")
return
}
if SecondTextField.text?.count == 0 { print("数字が表示されてないよ") return } override func viewDidLoad() { super.viewDidLoad() func showAller(){ let alert: UIAlertController = UIAlertController(title: "title", message: "message", preferredStyle: .alert) let action: UIAlertAction = UIAlertAction(title: title, style: .default, handler: nil) alert.addAction(action) present(alert, animated: true, completion: nil) } // Do any additional setup after loading the view. }
}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/13 12:10