728x90
import UIKit
import FirebaseAuth
class RegisterViewController: UIViewController {
@IBOutlet weak var emailTextfield: UITextField!
@IBOutlet weak var passwordTextfield: UITextField!
@IBAction func registerPressed(_ sender: UIButton) {
if let email = emailTextfield.text, let password = passwordTextfield.text {
Auth.auth().createUser(withEmail: email, password: password) { authResult, error in
if let e = error {
print(e.localizedDescription)
}
else {
self.performSegue(withIdentifier: "RegisterToChat", sender: self)
}
}
}
}
}
์ ์ฝ๋๋ ํ์๊ฐ์ ํ๋ฉด์์ ์ฑํ ํ๋ฉด์ผ๋ก ์ ํํ๋ performSeque ์ฝ๋์ด๋ค.
์ ํ Identifier ๊ฐ ๋ฌธ์์ด๋ก ์ ํ ์์ด์ ์คํ๊ฐ ์๊ธฐ๋ฉด ์ค๋ฅ๊ฐ ๋๊ณ , ๋๋ฒ๊น ์ด ํ๋ค๋ค.
์ด๋ฌํ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ๋ฌธ์์ด์ ๋ชจ์๋ ์์ํ์ผ์ ๋ง๋ค๋ฉด ์์คํ ์๋ฌ๋ฅผ ๋์์ ์ฆ๊ฐ ํด๊ฒฐ์ด ๊ฐ๋ฅํ๋ค.
[๋ฐฉ๋ฒ]
๋น swift ํ์ผ์ ๋ง๋ค์ด์ struct ๋ก ๋ณ์๋ค์ ์ ์ธํด์ค๋ค.
struct Constants{
static let registerSegue = "RegisterToChat"
static let loginSeque = "LoginToChat"
}
์ด ๋, static ์ผ๋ก ์ ์ธํด์ ๋ฐ๋ณต๋ ๊ฐ์ฒด ์์ฑ ์์ด ๋ฐ๋ก ํธ์ถํ ์ ์๋๋ก ํด์ค๋ค.
import UIKit
import FirebaseAuth
class RegisterViewController: UIViewController {
@IBOutlet weak var emailTextfield: UITextField!
@IBOutlet weak var passwordTextfield: UITextField!
@IBAction func registerPressed(_ sender: UIButton) {
if let email = emailTextfield.text, let password = passwordTextfield.text {
Auth.auth().createUser(withEmail: email, password: password) { authResult, error in
if let e = error {
print(e.localizedDescription)
}
else {
self.performSegue(withIdentifier: Constants.registerSegue, sender: self)
}
}
}
}
}
์์๋ก ๋ฐ๊พผ ๋ชจ์ต.
[Type Properties ๋ด์ฉ ์ฐธ๊ณ ]
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/properties/
728x90
'๐ฑ App Development Study > iOS๐' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Udemy iOS & Swift Bootcamp] Type Casting (0) | 2023.07.02 |
---|---|
[Udemy iOS & Swift Bootcamp] Table View(DataSource, Delegate) (0) | 2023.06.27 |
[Udemy iOS & Swift Bootcamp] 2. Firebase ์ฌ์ฉํ๊ธฐ(ํ์๊ฐ์ , ๋ก๊ทธ์ธ, ๋ก๊ทธ์์) (0) | 2023.06.20 |
[Udemy iOS & Swift Bootcamp] 1. Firebase ์ถ๊ฐํ๊ธฐ (0) | 2023.06.19 |
[Udemy iOS & Swift Bootcamp] 3rd Party Libraries & Cocoapods (1) | 2023.06.18 |