我收到了这个愚蠢的错误,但我无法找到它的来源。如果有人能够查看我的代码并不是很好,那么我可能会看到一些非常简单的东西!错误是"预期表达"在最后一行代码!谢谢!
//
// ViewController.swift
// intern
//
// Created by Lani Daniels on 8/1/17.
// Copyright © 2017 Lani Daniels. All rights reserved.
//
import UIKit
import Firebase
import FirebaseDatabase
import FirebaseAuth
class HomeViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var emailField: UITextField!
@IBOutlet weak var passwordField: UITextField!
@IBOutlet weak var actionButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
//Do any additional setup after loading the view, typically from a nib.
self.passwordField.delegate = self;
}
@IBAction func createNew(_ sender: Any) {
self.performSegue(withIdentifier: "createAccount", sender: self)
}
@IBAction func signInTapped(_ sender: Any) {
self.performSegue(withIdentifier: "toMM", sender: self)
if emailField.text != "" && passwordField.text != ""
{
Auth.auth().signIn(withEmail: emailField.text!, password: passwordField.text!, completion: { (user, error) in if user != nil
{
// Sign in successful
}
else
{
if let myError = error?.localizedDescription
{
print(myError)
}
else
{
print("ERROR")
}
}}
)
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
self.view.endEditing(true)
return false
)}}}} //ERROR: EXPECTED EXPRESSION
答案 0 :(得分:2)
几个关闭字符放错了地方。这是您的代码,格式正确:
//
// ViewController.swift
// intern
//
// Created by Lani Daniels on 8/1/17.
// Copyright © 2017 Lani Daniels. All rights reserved.
//
import UIKit
import Firebase
import FirebaseDatabase
import FirebaseAuth
class HomeViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var emailField: UITextField!
@IBOutlet weak var passwordField: UITextField!
@IBOutlet weak var actionButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
//Do any additional setup after loading the view, typically from a nib.
self.passwordField.delegate = self;
}
@IBAction func createNew(_ sender: Any) {
self.performSegue(withIdentifier: "createAccount", sender: self)
}
@IBAction func signInTapped(_ sender: Any) {
self.performSegue(withIdentifier: "toMM", sender: self)
if emailField.text != "" && passwordField.text != ""
{
Auth.auth().signIn(withEmail: emailField.text!, password: passwordField.text!, completion: { (user, error) in
if user != nil
{
// Sign in successful
}
else
{
if let myError = error?.localizedDescription
{
print(myError)
}
else
{
print("ERROR")
}
}
})
}
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
self.view.endEditing(true)
return false
}
}