質問編集履歴
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,3 +21,107 @@
|
|
21
21
|
|
22
22
|
|
23
23
|
よろしくお願いします。
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
### 該当のソースコード
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
```Swift
|
32
|
+
|
33
|
+
import UIKit
|
34
|
+
|
35
|
+
import Firebase
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
var auth: Auth!
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
class AccountViewController: UIViewController {
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
@IBOutlet var emailTextField: UITextField!
|
50
|
+
|
51
|
+
@IBOutlet var passwordTextField: UITextField!
|
52
|
+
|
53
|
+
@IBOutlet var usernameTextField: UITextField!
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
override func viewDidLoad() {
|
60
|
+
|
61
|
+
super.viewDidLoad()
|
62
|
+
|
63
|
+
auth = Auth.auth()
|
64
|
+
|
65
|
+
emailTextField.delegate = self
|
66
|
+
|
67
|
+
passwordTextField.delegate = self
|
68
|
+
|
69
|
+
usernameTextField.delegate = self
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
@IBAction func registerAccount(_ sender: Any) {
|
80
|
+
|
81
|
+
let email = emailTextField.text!
|
82
|
+
|
83
|
+
let password = passwordTextField.text!
|
84
|
+
|
85
|
+
let username = usernameTextField.text!
|
86
|
+
|
87
|
+
auth.createUser(withEmail: email, password: password) { (result,error) in
|
88
|
+
|
89
|
+
if error == nil, let result = result {
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
self.performSegue(withIdentifier: "Timeline", sender: result.user)
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
// デリゲートメソッドは可読性のためextensionで分けて記述します。
|
114
|
+
|
115
|
+
extension AccountViewController: UITextFieldDelegate {
|
116
|
+
|
117
|
+
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
118
|
+
|
119
|
+
textField.resignFirstResponder()
|
120
|
+
|
121
|
+
return true
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
```
|