質問編集履歴

2

追加

2020/04/22 08:16

投稿

se_taro
se_taro

スコア6

test CHANGED
File without changes
test CHANGED
@@ -13,6 +13,86 @@
13
13
 
14
14
 
15
15
  ```Swift
16
+
17
+ class RegisterViewController: UIViewController, UITextFieldDelegate {
18
+
19
+
20
+
21
+ // 登録ボタン
22
+
23
+ @IBOutlet weak var Button: UIButton!
24
+
25
+ @IBOutlet weak var newname: UITextField!
26
+
27
+ @IBOutlet weak var newmail: UITextField!
28
+
29
+ @IBOutlet weak var newpass: UITextField!
30
+
31
+ @IBOutlet weak var newpass2: UITextField!
32
+
33
+
34
+
35
+ @IBAction func back_button(_ sender: Any) {
36
+
37
+ self.navigationController?.popViewController(animated: true)
38
+
39
+ }
40
+
41
+
42
+
43
+ // 登録ボタン
44
+
45
+ @IBAction func register(_ sender: Any) {
46
+
47
+
48
+
49
+ // https://teachapi.herokuapp.com/sign_up
50
+
51
+ let config: URLSessionConfiguration = URLSessionConfiguration.default
52
+
53
+
54
+
55
+ let session: URLSession = URLSession(configuration: config)
56
+
57
+
58
+
59
+ var urlComponents = URLComponents()
60
+
61
+ urlComponents.scheme = "https"
62
+
63
+ urlComponents.host = "teachapi.herokuapp.com"
64
+
65
+ urlComponents.path = "/sign_up"
66
+
67
+
68
+
69
+
70
+
71
+ let url: URL = urlComponents.url!
72
+
73
+ var req: URLRequest = URLRequest(url: url)
74
+
75
+ req.httpMethod = "POST"
76
+
77
+ req.addValue("application/json", forHTTPHeaderField: "Content-Type")
78
+
79
+ let params:[String:Any] = [
80
+
81
+ "sign_up_user_params": [
82
+
83
+ "name": "(newname.text!)",
84
+
85
+ "bio": "a",
86
+
87
+ "email": "(newmail.text!)",
88
+
89
+ "password": "(newpass.text!)",
90
+
91
+ "password_confirmation": "(newpass2.text!)"
92
+
93
+ ]
94
+
95
+ ]
16
96
 
17
97
  func textFieldDidEndEditing(_ textField: UITextField) {
18
98
 

1

誤字

2020/04/22 08:16

投稿

se_taro
se_taro

スコア6

test CHANGED
File without changes
test CHANGED
@@ -34,7 +34,7 @@
34
34
 
35
35
  let task = session.dataTask(with: req) { (data, response, error) in
36
36
 
37
- // tokenせーぶしてるコード。これを登録とかログインに書くとどこでもtoken使えるようになる
37
+
38
38
 
39
39
  do {
40
40