I want to pass the value "Email" from one VC to another when I press the button. So i want create a sign up with firebase and swift 4, first a view controller asks me the email, after entering the email, I click on next, and another view controller will ask me for the password, then click on register. How do I save the email of first ViewController and pass it to the second ViewController? And then send email of first vc and password of second vc to firebase? sorry for my english. In practice it must work like the instagram sign up.
import Foundation
import Firebase
import FirebaseAuth
import UITextField_Shake
internal class SignUpSegue0 : UIViewController {
@IBOutlet weak var labelwrongpass: UILabel!
@IBOutlet weak var Emailsign: UITextField!
func isValidEmail(testStr:String) -> Bool {
print("validate emilId: \(testStr)")
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"
let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
let result = emailTest.evaluate(with: testStr)
return result
}
@IBAction func Nextsign1(_ sender: UIButton) {
guard let email = Emailsign.text else { return }
if Emailsign.text == "" {
self.labelwrongpass.text = "Please enter your email"
self.Emailsign.shake(10,withDelta: 5.0)
} else {
Auth.auth().fetchProviders(forEmail: email, completion: {
(providers, error) in
if error != nil {
print("Email disponibile")
self.labelwrongpass.text = "Email inserita correttamente"
self.labelwrongpass.textColor = UIColor.green
func prepare(for segue: UIStoryboardSegue, sender: Any?)
{
if segue.destination is SignUpSegue1
{
let vc = segue.destination as? SignUpSegue1
vc?.email = ""
}
}
} else if providers != nil {
print("L'email inserita è già esistente")
self.labelwrongpass.text = nil
self.labelwrongpass.text = "L'email inserita è già esistente"
self.Emailsign.shake(10,withDelta: 5.0)
}
})
}
}
}