Post

Replies

Boosts

Views

Activity

function not transfer to vc
I made an extension to UIViewController and inside i have function I use several times: extension UIViewController {   func transitionToHomeVC() {     let homeViewController = self.storyboard?.instantiateViewController(withIdentifier: NameConstants.StoryBoard.homeViewController) as? HomeViewController     self.view.window?.rootViewController = homeViewController     self.view.window?.makeKeyAndVisible()   } } And I have a registration button and as soon as you click if the information was received and correct and etc ... then he has to move me at the to the HomeViewController screen and he does not do it. He does all the actions but does not pass to screen. @IBAction func signUpTapped(_ sender: Any) {     // Validate the fields     let error = validDataFields()     if error != nil {       // There's something wrong with the fields, show error message       Service.showError(vc: self, message: error!)     }     else {       // Create cleaned versions of the data       let fireName = firstNameTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)       let lastName = lastNameTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)       let email = emailTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)       let password = passwordTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)            // Create the user       Auth.auth().createUser(withEmail: email, password: password) { resulte, err in         // Check for errors         if err != nil {           // There was an error creating the user           Service.showError(vc: self, message: "Error creating user \n make sure you enter: \n current email")         }         else {           // User was created successfully, now store the first name and last name           let db = Firestore.firestore()           db.collection("users").addDocument(data: ["firstName":fireName,"lastName":lastName, "uid": resulte!.user.uid]) { error in             if error != nil {               // Show error message               Service.showError(vc: self, message: " Error saving user Data")             }           }           self.transitionToHomeVC()         }       }     }   }     why it not move to homeViewController?
8
0
960
Jul ’22
Instance member 'present' cannot be used on type 'Service'
class Service: UIViewController {       static func showError(_ message:String) {     // Create new Alert     let dialogMessage = UIAlertController(title: "Error", message: message, preferredStyle: .alert)           // Create OK button with action handler     let ok = UIAlertAction(title: "OK", style: .default, handler: { (action) -> Void in       print("Ok button tapped")     })           //Add OK button to a dialog message     dialogMessage.addAction(ok)     // Present Alert to     self.present(dialogMessage , animated: true, completion: nil)         } } why i get error in this line: self.present(dialogMessage , animated: true, completion: nil) the error: Instance member 'present' cannot be used on type 'Service' why?
1
0
1.2k
Jun ’22