// // firstView.swift // juego // // Created by Mobile Roshka on 3/5/20. // Copyright © 2020 Mobile Roshka. All rights reserved. // import Foundation import UIKit class FirstViewController: UIViewController { var playerName = "" @IBAction func nameTextField(_ sender: Any) { } @IBOutlet weak var nameTextFieldInput: UITextField! @IBAction func saveBtn(_ sender: Any) { if let pName = nameTextFieldInput.text{ playerName = pName showAlert(message: "\(playerName) registrado correctamente") } else { showAlert(message: "No se ha registrado ningun jugador") } } private func showAlert(message: String){ let alert = UIAlertController(title: "Registrar Jugador", message:message, preferredStyle: .alert) alert.addAction(UIAlertAction(title: "Aceptar", style: .default, handler: nil)) present(alert, animated:true, completion:nil) } override func viewDidLoad() { super.viewDidLoad() } @IBAction func enterBtn(_ sender: Any) { let hVC = self.storyboard?.instantiateViewController(withIdentifier: "homeVC") as! HomeViewControler hVC.name = playerName } }