質問編集履歴

9

本文修正

2017/11/30 11:45

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -14,11 +14,11 @@
14
14
 
15
15
  ①Email,PasswordのフォームとLog in,Sign Upのボタンの画面。
16
16
 
17
- ②Sign Upボタンから遷移する
17
+ ②Sign Upボタンから遷移した先は
18
-
18
+
19
- Full Name,E mail,Password,Confirm Passwordのフ
19
+ Full Name,E mail,Passwordなどテキストルド
20
-
20
+
21
- UIImage View,Select Picture,Nextのボタン画面。
21
+ UIImage View,Select Picture,Nextのボタンがある画面。
22
22
 
23
23
 
24
24
 

8

本文修正

2017/11/30 11:45

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,7 +1,5 @@
1
1
  ![イメージ説明](d8e21d025873b67e46b2150b89b81d7f.png)
2
2
 
3
-
4
-
5
3
  Swift 4
6
4
 
7
5
  Xcode 9.1
@@ -10,9 +8,9 @@
10
8
 
11
9
  インスタグラムのクローンを作っています。
12
10
 
11
+
12
+
13
- ストーリーボード上は下記2つの画面があります
13
+ (ストーリーボード上は下記2つの画面があります)
14
-
15
-
16
14
 
17
15
  ①Email,PasswordのフォームとLog in,Sign Upのボタンの画面。
18
16
 
@@ -28,27 +26,23 @@
28
26
 
29
27
 
30
28
 
31
-
32
-
33
- 確認した点
29
+ (確認した点)
34
-
30
+
35
- ・triggered seguesの中で、使用していないラベルは無かった
31
+ ・triggered seguesの中で、使用していラベルのみ結ばれている
36
-
32
+
37
- ・メインストーリーボードでSignupViewController.swiftを右クリックした中に、
33
+ ・メインストーリーボードでSignupViewController.swiftを右クリックした中に、
38
-
34
+
39
- 黄色い△(警告)は無かった
35
+ イエローフラッグは無
40
-
41
-
42
-
36
+
37
+
38
+
43
- 試した方法
39
+ (試した方法)
44
40
 
45
41
  ・SignupViewController.swift上のIBOutletとIBActionから始まるコードを
46
42
 
47
- 全て消して書き直しました
48
-
49
-
50
-
51
- 再度ビルドしても同様にクラッシュしました。
43
+ 全て消して書き直し、再度ビルドしてもクラッシュしました。
44
+
45
+
52
46
 
53
47
  お分かりになる方、どうぞご教授お願います。
54
48
 

7

本文修正

2017/11/30 02:24

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -241,3 +241,5 @@
241
241
  )}}
242
242
 
243
243
  }
244
+
245
+ ```

6

本文修正

2017/11/30 02:09

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
File without changes

5

本文修正

2017/11/30 02:07

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,7 @@
1
+ ![イメージ説明](d8e21d025873b67e46b2150b89b81d7f.png)
2
+
3
+
4
+
1
5
  Swift 4
2
6
 
3
7
  Xcode 9.1
@@ -20,15 +24,9 @@
20
24
 
21
25
 
22
26
 
23
-
24
-
25
- Sign Upをクリックすると、遷移されず、
26
-
27
- 下記フォトの様にクラッシュし、Thread 1: signal SIGABRTと表示されます。
27
+ Sign Upをリックすると、遷移されずクラッシュし、Thread 1: signal SIGABRTと表示されます。
28
-
29
-
30
-
31
- ![イメージ説明](e7e7bbf7e7048d6c3893e534246f3fa4.png)//
28
+
29
+
32
30
 
33
31
 
34
32
 
@@ -58,96 +56,188 @@
58
56
 
59
57
  ```
60
58
 
61
- 2017-11-30 10:54:18.654470+0900 instagram_001[623:9148] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKeyedSubscript:]: key cannot be nil'
62
-
63
- *** First throw call stack:
64
-
65
- (
66
-
67
- 0 CoreFoundation 0x00000001057611ab __exceptionPreprocess + 171
68
-
69
- 1 libobjc.A.dylib 0x0000000104df6f41 objc_exception_throw + 48
70
-
71
- 2 CoreFoundation 0x00000001057a0f9c _CFThrowFormattedException + 194
72
-
73
- 3 CoreFoundation 0x000000010580632a -[__NSDictionaryM setObject:forKeyedSubscript:] + 970
74
-
75
- 4 instagram_001 0x0000000102dda067 +[FRepoManager createRepo:config:database:] + 273
76
-
77
- 5 instagram_001 0x0000000102dc170d -[FIRDatabase ensureRepo] + 151
78
-
79
- 6 instagram_001 0x0000000102dc0e05 -[FIRDatabase reference] + 31
80
-
81
- 7 instagram_001 0x0000000102d11a96 _T013instagram_00120SignupViewControllerC11viewDidLoadyyF + 470
82
-
83
- 8 instagram_001 0x0000000102d11cf4 _T013instagram_00120SignupViewControllerC11viewDidLoadyyFTo + 36
84
-
85
- 9 UIKit 0x00000001064928a5 -[UIViewController loadViewIfRequired] + 1235
86
-
87
- 10 UIKit 0x0000000106492cf2 -[UIViewController view] + 27
88
-
89
- 11 UIKit 0x0000000106f223a9 -[_UIFullscreenPresentationController _setPresentedViewController:] + 89
90
-
91
- 12 UIKit 0x0000000106460ba7 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 133
92
-
93
- 13 UIKit 0x00000001064a5f6a -[UIViewController _presentViewController:withAnimationController:completion:] + 3808
94
-
95
- 14 UIKit 0x00000001064a8dad __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 99
96
-
97
- 15 UIKit 0x00000001064a947d -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 532
98
-
99
- 16 UIKit 0x00000001064a8d0c -[UIViewController _presentViewController:animated:completion:] + 181
100
-
101
- 17 UIKit 0x00000001064a906b -[UIViewController presentViewController:animated:completion:] + 159
102
-
103
- 18 UIKit 0x00000001064ae3ee -[UIViewController _showViewController:withAction:sender:] + 274
104
-
105
- 19 UIKit 0x0000000106a56643 __66-[UIStoryboardShowSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 134
106
-
107
- 20 UIKit 0x0000000106c14dcb -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 279
108
-
109
- 21 UIKit 0x0000000106c14c83 -[UIStoryboardSegueTemplate _perform:] + 82
110
-
111
- 22 UIKit 0x0000000106c14f4b -[UIStoryboardSegueTemplate perform:] + 157
112
-
113
- 23 UIKit 0x00000001062ef275 -[UIApplication sendAction:to:from:forEvent:] + 83
114
-
115
- 24 UIKit 0x000000010646c4a2 -[UIControl sendAction:to:forEvent:] + 67
116
-
117
- 25 UIKit 0x000000010646c7bf -[UIControl _sendActionsForEvents:withEvent:] + 450
118
-
119
- 26 UIKit 0x000000010646b6ec -[UIControl touchesEnded:withEvent:] + 618
120
-
121
- 27 UIKit 0x0000000106364bbb -[UIWindow _sendTouchesForEvent:] + 2807
122
-
123
- 28 UIKit 0x00000001063662de -[UIWindow sendEvent:] + 4124
124
-
125
- 29 UIKit 0x0000000106309e36 -[UIApplication sendEvent:] + 352
126
-
127
- 30 UIKit 0x0000000106c4c434 __dispatchPreprocessedEventFromEventQueue + 2809
128
-
129
- 31 UIKit 0x0000000106c4f089 __handleEventQueueInternal + 5957
130
-
131
- 32 CoreFoundation 0x0000000105704231 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
132
-
133
- 33 CoreFoundation 0x00000001057a3e41 __CFRunLoopDoSource0 + 81
134
-
135
- 34 CoreFoundation 0x00000001056e8b49 __CFRunLoopDoSources0 + 185
136
-
137
- 35 CoreFoundation 0x00000001056e812f __CFRunLoopRun + 1279
138
-
139
- 36 CoreFoundation 0x00000001056e79b9 CFRunLoopRunSpecific + 409
140
-
141
- 37 GraphicsServices 0x000000010a8869c6 GSEventRunModal + 62
142
-
143
- 38 UIKit 0x00000001062ed5e8 UIApplicationMain + 159
144
-
145
- 39 instagram_001 0x0000000102d18837 main + 55
146
-
147
- 40 libdyld.dylib 0x0000000109109d81 start + 1
148
-
149
- )
150
-
151
- libc++abi.dylib: terminating with uncaught exception of type NSException
152
-
153
- (lldb)
59
+ //
60
+
61
+ // SignupViewController.swift
62
+
63
+ // instagram_001
64
+
65
+ //
66
+
67
+
68
+
69
+ import UIKit
70
+
71
+ import Firebase
72
+
73
+
74
+
75
+ class SignupViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
76
+
77
+ @IBOutlet weak var nameField: UITextField!
78
+
79
+ @IBOutlet weak var emailField: UITextField!
80
+
81
+ @IBOutlet weak var password: UITextField!
82
+
83
+ @IBOutlet weak var comPwField: UITextField!
84
+
85
+ @IBOutlet weak var imageView: UIImageView!
86
+
87
+ @IBOutlet weak var nextBtn: UIButton!
88
+
89
+
90
+
91
+ let picker = UIImagePickerController()
92
+
93
+ var userStorage: StorageReference!
94
+
95
+ var ref: DatabaseReference!
96
+
97
+
98
+
99
+ override func viewDidLoad() {
100
+
101
+ super.viewDidLoad()
102
+
103
+
104
+
105
+ picker.delegate = self
106
+
107
+
108
+
109
+ let storage = Storage.storage().reference(forURL: "gs://instagram-f049d.appspot.com")
110
+
111
+
112
+
113
+ ref = FirebaseDatabase.Database().reference()
114
+
115
+
116
+
117
+ userStorage = storage.child("users")
118
+
119
+ }
120
+
121
+ @IBAction func selectimagePressed(_ sender: Any) {
122
+
123
+ picker.allowsEditing = true
124
+
125
+ picker.sourceType = .photoLibrary
126
+
127
+
128
+
129
+ present(picker, animated: true, completion: nil)
130
+
131
+ }
132
+
133
+ func imagePickerController( _ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
134
+
135
+ if let image = info[UIImagePickerControllerEditedImage] as? UIImage {
136
+
137
+ self.imageView.image = image
138
+
139
+ nextBtn.isHidden = false
140
+
141
+ }
142
+
143
+ self.dismiss(animated: true, completion: nil)
144
+
145
+ }
146
+
147
+ @IBAction func nextPressed(_ sender: Any) {
148
+
149
+
150
+
151
+ guard nameField.text != "", emailField.text != "", password.text != "", comPwField.text != "" else { return}
152
+
153
+ if password.text == comPwField.text {
154
+
155
+ Auth.auth().createUser(withEmail: emailField.text!, password: password.text!,
156
+
157
+ completion: { (user,error) in
158
+
159
+
160
+
161
+ if let error = error {
162
+
163
+ print(error.localizedDescription)
164
+
165
+ }
166
+
167
+ if let user = user {
168
+
169
+
170
+
171
+ let changeRequest = Auth.auth().currentUser!.createProfileChangeRequest()
172
+
173
+ changeRequest.displayName = self.nameField.text!
174
+
175
+ changeRequest.commitChanges(completion: nil)
176
+
177
+
178
+
179
+ let imageRef = self.userStorage.child("(user.uid).jpg")
180
+
181
+
182
+
183
+ let data = UIImageJPEGRepresentation(self.imageView.image!, 0.5)
184
+
185
+
186
+
187
+ let uploadTask = imageRef.putData(data!, metadata: nil, completion: { (metadata, err) in
188
+
189
+ if err != nil {
190
+
191
+ print(err!.localizedDescription)
192
+
193
+ }
194
+
195
+ imageRef.downloadURL(completion: { (url, er) in
196
+
197
+ if er != nil {
198
+
199
+ print(er!.localizedDescription)
200
+
201
+ }
202
+
203
+ if let url = url {
204
+
205
+ let userInfo: [String : Any] = ["uid" : user.uid,
206
+
207
+ "full name" : self.nameField.text!,
208
+
209
+ "urlToImage" : url.absoluteString]
210
+
211
+
212
+
213
+ self.ref.child("users").child(user.uid).setValue(userInfo)
214
+
215
+
216
+
217
+ let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "userVC")
218
+
219
+
220
+
221
+ self.present(vc, animated: true, completion: nil)
222
+
223
+ }
224
+
225
+ } )
226
+
227
+ })
228
+
229
+ uploadTask.resume()
230
+
231
+
232
+
233
+ } else {
234
+
235
+ print("password does not match")
236
+
237
+ }
238
+
239
+ }
240
+
241
+ )}}
242
+
243
+ }

4

本文編集

2017/11/30 02:05

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -58,188 +58,96 @@
58
58
 
59
59
  ```
60
60
 
61
- // SignupViewController.swift
61
+ 2017-11-30 10:54:18.654470+0900 instagram_001[623:9148] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKeyedSubscript:]: key cannot be nil'
62
62
 
63
- // instagram_001
63
+ *** First throw call stack:
64
64
 
65
- //
65
+ (
66
66
 
67
+ 0 CoreFoundation 0x00000001057611ab __exceptionPreprocess + 171
67
68
 
69
+ 1 libobjc.A.dylib 0x0000000104df6f41 objc_exception_throw + 48
68
70
 
69
- import UIKit
71
+ 2 CoreFoundation 0x00000001057a0f9c _CFThrowFormattedException + 194
70
72
 
71
- import Firebase
73
+ 3 CoreFoundation 0x000000010580632a -[__NSDictionaryM setObject:forKeyedSubscript:] + 970
72
74
 
75
+ 4 instagram_001 0x0000000102dda067 +[FRepoManager createRepo:config:database:] + 273
73
76
 
77
+ 5 instagram_001 0x0000000102dc170d -[FIRDatabase ensureRepo] + 151
74
78
 
75
- class SignupViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
79
+ 6 instagram_001 0x0000000102dc0e05 -[FIRDatabase reference] + 31
76
80
 
77
- @IBOutlet weak var nameField: UITextField!
81
+ 7 instagram_001 0x0000000102d11a96 _T013instagram_00120SignupViewControllerC11viewDidLoadyyF + 470
78
82
 
79
- @IBOutlet weak var emailField: UITextField!
83
+ 8 instagram_001 0x0000000102d11cf4 _T013instagram_00120SignupViewControllerC11viewDidLoadyyFTo + 36
80
84
 
81
- @IBOutlet weak var password: UITextField!
85
+ 9 UIKit 0x00000001064928a5 -[UIViewController loadViewIfRequired] + 1235
82
86
 
83
- @IBOutlet weak var comPwField: UITextField!
87
+ 10 UIKit 0x0000000106492cf2 -[UIViewController view] + 27
84
88
 
85
- @IBOutlet weak var imageView: UIImageView!
89
+ 11 UIKit 0x0000000106f223a9 -[_UIFullscreenPresentationController _setPresentedViewController:] + 89
86
90
 
87
- @IBOutlet weak var nextBtn: UIButton!
91
+ 12 UIKit 0x0000000106460ba7 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 133
88
92
 
89
-
93
+ 13 UIKit 0x00000001064a5f6a -[UIViewController _presentViewController:withAnimationController:completion:] + 3808
90
94
 
91
- let picker = UIImagePickerController()
95
+ 14 UIKit 0x00000001064a8dad __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 99
92
96
 
93
- var userStorage: StorageReference!
97
+ 15 UIKit 0x00000001064a947d -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 532
94
98
 
95
- var ref: DatabaseReference!
99
+ 16 UIKit 0x00000001064a8d0c -[UIViewController _presentViewController:animated:completion:] + 181
96
100
 
97
-
101
+ 17 UIKit 0x00000001064a906b -[UIViewController presentViewController:animated:completion:] + 159
98
102
 
99
- override func viewDidLoad() {
103
+ 18 UIKit 0x00000001064ae3ee -[UIViewController _showViewController:withAction:sender:] + 274
100
104
 
101
- super.viewDidLoad()
105
+ 19 UIKit 0x0000000106a56643 __66-[UIStoryboardShowSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 134
102
106
 
103
-
107
+ 20 UIKit 0x0000000106c14dcb -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 279
104
108
 
105
- picker.delegate = self
109
+ 21 UIKit 0x0000000106c14c83 -[UIStoryboardSegueTemplate _perform:] + 82
106
110
 
107
-
111
+ 22 UIKit 0x0000000106c14f4b -[UIStoryboardSegueTemplate perform:] + 157
108
112
 
109
- let storage = Storage.storage().reference(forURL: "gs://instagram-f049d.appspot.com")
113
+ 23 UIKit 0x00000001062ef275 -[UIApplication sendAction:to:from:forEvent:] + 83
110
114
 
111
-
115
+ 24 UIKit 0x000000010646c4a2 -[UIControl sendAction:to:forEvent:] + 67
112
116
 
113
- ref = FirebaseDatabase.Database().reference()
117
+ 25 UIKit 0x000000010646c7bf -[UIControl _sendActionsForEvents:withEvent:] + 450
114
118
 
115
-
119
+ 26 UIKit 0x000000010646b6ec -[UIControl touchesEnded:withEvent:] + 618
116
120
 
117
- userStorage = storage.child("users")
121
+ 27 UIKit 0x0000000106364bbb -[UIWindow _sendTouchesForEvent:] + 2807
118
122
 
119
- }
123
+ 28 UIKit 0x00000001063662de -[UIWindow sendEvent:] + 4124
120
124
 
121
- @IBAction func selectimagePressed(_ sender: Any) {
125
+ 29 UIKit 0x0000000106309e36 -[UIApplication sendEvent:] + 352
122
126
 
123
- picker.allowsEditing = true
127
+ 30 UIKit 0x0000000106c4c434 __dispatchPreprocessedEventFromEventQueue + 2809
124
128
 
125
- picker.sourceType = .photoLibrary
129
+ 31 UIKit 0x0000000106c4f089 __handleEventQueueInternal + 5957
126
130
 
127
-
131
+ 32 CoreFoundation 0x0000000105704231 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
128
132
 
129
- present(picker, animated: true, completion: nil)
133
+ 33 CoreFoundation 0x00000001057a3e41 __CFRunLoopDoSource0 + 81
130
134
 
131
- }
135
+ 34 CoreFoundation 0x00000001056e8b49 __CFRunLoopDoSources0 + 185
132
136
 
133
- func imagePickerController( _ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
137
+ 35 CoreFoundation 0x00000001056e812f __CFRunLoopRun + 1279
134
138
 
135
- if let image = info[UIImagePickerControllerEditedImage] as? UIImage {
139
+ 36 CoreFoundation 0x00000001056e79b9 CFRunLoopRunSpecific + 409
136
140
 
137
- self.imageView.image = image
141
+ 37 GraphicsServices 0x000000010a8869c6 GSEventRunModal + 62
138
142
 
139
- nextBtn.isHidden = false
143
+ 38 UIKit 0x00000001062ed5e8 UIApplicationMain + 159
140
144
 
141
- }
145
+ 39 instagram_001 0x0000000102d18837 main + 55
142
146
 
143
- self.dismiss(animated: true, completion: nil)
147
+ 40 libdyld.dylib 0x0000000109109d81 start + 1
144
148
 
145
- }
149
+ )
146
150
 
147
- @IBAction func nextPressed(_ sender: Any) {
151
+ libc++abi.dylib: terminating with uncaught exception of type NSException
148
152
 
149
-
150
-
151
- guard nameField.text != "", emailField.text != "", password.text != "", comPwField.text != "" else { return}
152
-
153
- if password.text == comPwField.text {
154
-
155
- Auth.auth().createUser(withEmail: emailField.text!, password: password.text!,
156
-
157
- completion: { (user,error) in
158
-
159
-
160
-
161
- if let error = error {
162
-
163
- print(error.localizedDescription)
164
-
165
- }
166
-
167
- if let user = user {
168
-
169
-
170
-
171
- let changeRequest = Auth.auth().currentUser!.createProfileChangeRequest()
172
-
173
- changeRequest.displayName = self.nameField.text!
174
-
175
- changeRequest.commitChanges(completion: nil)
176
-
177
-
178
-
179
- let imageRef = self.userStorage.child("(user.uid).jpg")
180
-
181
-
182
-
183
- let data = UIImageJPEGRepresentation(self.imageView.image!, 0.5)
184
-
185
-
186
-
187
- let uploadTask = imageRef.putData(data!, metadata: nil, completion: { (metadata, err) in
188
-
189
- if err != nil {
190
-
191
- print(err!.localizedDescription)
192
-
193
- }
194
-
195
- imageRef.downloadURL(completion: { (url, er) in
196
-
197
- if er != nil {
198
-
199
- print(er!.localizedDescription)
200
-
201
- }
202
-
203
- if let url = url {
204
-
205
- let userInfo: [String : Any] = ["uid" : user.uid,
206
-
207
- "full name" : self.nameField.text!,
208
-
209
- "urlToImage" : url.absoluteString]
210
-
211
-
212
-
213
- self.ref.child("users").child(user.uid).setValue(userInfo)
214
-
215
-
216
-
217
- let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "userVC")
218
-
219
-
220
-
221
- self.present(vc, animated: true, completion: nil)
222
-
223
- }
224
-
225
- } )
153
+ (lldb)
226
-
227
- })
228
-
229
- uploadTask.resume()
230
-
231
-
232
-
233
- } else {
234
-
235
- print("password does not match")
236
-
237
- }
238
-
239
- }
240
-
241
- )}}
242
-
243
- }
244
-
245
- ```

3

コードの編集

2017/11/30 02:02

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -56,6 +56,8 @@
56
56
 
57
57
 
58
58
 
59
+ ```
60
+
59
61
  // SignupViewController.swift
60
62
 
61
63
  // instagram_001
@@ -239,3 +241,5 @@
239
241
  )}}
240
242
 
241
243
  }
244
+
245
+ ```

2

本文修正

2017/11/30 01:52

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  Swift 4
2
2
 
3
- Version 9.1
3
+ Xcode 9.1
4
4
 
5
5
 
6
6
 

1

本文修正

2017/11/29 13:25

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,9 @@
1
+ Swift 4
2
+
3
+ Version 9.1
4
+
5
+
6
+
1
7
  インスタグラムのクローンを作っています。
2
8
 
3
9
  ストーリーボード上は下記2つの画面があります。