-1
我不知道爲什麼我無法從UITextField訪問文本。爲什麼我不能訪問UITextField的文本?
這裏是我的代碼:
import UIKit
import Firebase
import FirebaseAuth
class MessagesVC: UIViewController {
@IBOutlet weak var emailTextInput: UITextField! //Email Text Input
@IBOutlet weak var passwordTextInput: UITextField! //Password Text Input
var emailText: emailTextInput.text; //I get the error 'Use of undeclared type emailTextInput here.'
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func login(_ sender: Any) {
} //Login
@IBAction func signUp(_ sender: Any) {
Auth.auth().createUser(withEmail: , password:) { (user, error) in
} //Authentication Create User
} //Sign Up
} //Class
這是編輯錯誤,我得到:
VAR emailText = emailTextInput.text –
用於聲明變量的Swift語法如下var/let nameOfVariable:TypeOfVariable = ValueforVariable –
這沒有奏效,它剛剛出現與:「不能在屬性初始值設定項中使用實例成員'emailTextInput';屬性初始值設定項在「自我」可用之前運行「 –