Ошибка «{ожидается после оператора if»
Я пытаюсь настроить Firebase в своем приложении и пытаюсь добавить несколько условий, если чья-либо информация для входа неверна. я добавилuser, error in
, По какой-то причине я могу заставить заявления if работать правильно. Любая строка со следующимif error!=nil{
приходит с ошибкойexpected "{" after if declaration
//
// RegistrationViewController.swift
// StudyBuddy
//
// Created by Basel Anani on 7/25/16.
// Copyright © 2016 StudyBuddy. All rights reserved.
//
import UIKit
import Firebase
class RegistrationViewController: UIViewController {
@IBOutlet weak var userEmailTextField: UITextField!
@IBOutlet weak var userPasswordTextField: UITextField!
@IBOutlet weak var userConfirmPasswordTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func registerButtonTapped(sender: AnyObject) {
let userEmail = userEmailTextField.text;
let userPassword = userPasswordTextField.text;
let userConfirmPassword = userConfirmPasswordTextField.text;
//Check for Empty Fields
FIRAuth.auth()?.createUserWithEmail(userEmailTextField.text!, password: userPasswordTextField.text!, completion: {
user, error in
if error !=nil{
}
else {
print("User Created")
self.login()
}
})
func login(){
FIRAuth.auth()?.signInWithEmail(userEmailTextField.text!, password: userPasswordTextField.text!, completion: {
user, error in
if error !=nil {
print("Incorrect")
}
else{
print("Login Successful")
}
})
//Save Stored Data
func displayMyAlertMessage(userMessage:String) {
var myAlert = UIAlertController(title: "Alert", message: "userMessage", preferredStyle: UIAlertControllerStyle.Alert);
let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil);
myAlert.addAction(okAction);
self.presentViewController(myAlert, animated: true, completion: nil);
if (userEmail!.isEmpty) {
displayMyAlertMessage("All fields are required");
return;
}
if (userPassword!.isEmpty) {
displayMyAlertMessage("All fields are required");
return;
}
if (userConfirmPassword!.isEmpty) {
displayMyAlertMessage("All fields are required");
return;
}
if userPassword != userConfirmPassword {
displayMyAlertMessage("Passwords do not match");
}
}
}}}