質問編集履歴
4
本文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -112,4 +112,4 @@
|
|
112
112
|
|
113
113
|
|
114
114
|
|
115
|
-
[参考](https://watchcontents.com/swift-appdelegate-method/)
|
115
|
+
[参考ページ](https://watchcontents.com/swift-appdelegate-method/)
|
3
本文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -109,3 +109,7 @@
|
|
109
109
|
|
110
110
|
|
111
111
|
```
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
[参考](https://watchcontents.com/swift-appdelegate-method/)
|
2
本文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
appDelegateからHomeViewControllerのメソッド```h
|
1
|
+
appDelegateからHomeViewControllerのメソッド```hello()```を呼び出そうとしたところ
|
2
2
|
|
3
3
|
こちらのエラーが表示されアプリが落ちてしまいます。
|
4
4
|
|
1
本文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,10 +19,6 @@
|
|
19
19
|
```
|
20
20
|
|
21
21
|
import UIKit
|
22
|
-
|
23
|
-
import NCMB
|
24
|
-
|
25
|
-
import AuthenticationServices
|
26
22
|
|
27
23
|
|
28
24
|
|
@@ -46,91 +42,15 @@
|
|
46
42
|
|
47
43
|
|
48
44
|
|
49
|
-
|
45
|
+
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
50
46
|
|
51
|
-
|
47
|
+
appDelegate.homeViewController.hello()//ここでエラー表示される落ちる
|
52
48
|
|
53
|
-
|
49
|
+
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
// APIキーの設定とSDK初期化
|
58
|
-
|
59
|
-
NCMB.initialize(applicationKey: applicationKey, clientKey: clientKey);
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
// on the initial view controller or somewhere else, check the userdefaults
|
64
|
-
|
65
|
-
if let userID = UserDefaults.standard.string(forKey: "userID") {
|
66
|
-
|
67
|
-
// move to main view
|
68
|
-
|
69
|
-
print("以前にログイン済み")
|
70
|
-
|
71
|
-
print(userID)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
78
|
-
|
79
|
-
appDelegate.homeViewController.handleASCredential()//ここでエラー表示される落ちる
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
}else{
|
86
|
-
|
87
|
-
goLoginViewConroller()
|
88
|
-
|
89
|
-
}
|
90
|
-
|
91
|
-
|
92
50
|
|
93
51
|
return true
|
94
52
|
|
95
|
-
}
|
53
|
+
}
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
//ログインコントローラーに遷移
|
100
|
-
|
101
|
-
func goLoginViewConroller(){
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
DispatchQueue.main.async {
|
106
|
-
|
107
|
-
//画面遷移させたい部分に以下の処理を記述
|
108
|
-
|
109
|
-
// windowを生成
|
110
|
-
|
111
|
-
self.window = UIWindow(frame: UIScreen.main.bounds)
|
112
|
-
|
113
|
-
// Storyboardを指定
|
114
|
-
|
115
|
-
let storyboard = UIStoryboard(name: "Main", bundle: nil)
|
116
|
-
|
117
|
-
// Viewcontrollerを指定
|
118
|
-
|
119
|
-
let loginViewController = storyboard.instantiateViewController(withIdentifier:"login")
|
120
|
-
|
121
|
-
// rootViewControllerに入れる
|
122
|
-
|
123
|
-
self.window?.rootViewController = loginViewController
|
124
|
-
|
125
|
-
// 表示
|
126
|
-
|
127
|
-
self.window?.makeKeyAndVisible()
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
}
|
132
|
-
|
133
|
-
|
134
54
|
|
135
55
|
}
|
136
56
|
|
@@ -147,8 +67,6 @@
|
|
147
67
|
```
|
148
68
|
|
149
69
|
import UIKit
|
150
|
-
|
151
|
-
import AuthenticationServices
|
152
70
|
|
153
71
|
|
154
72
|
|
@@ -180,67 +98,11 @@
|
|
180
98
|
|
181
99
|
|
182
100
|
|
183
|
-
|
101
|
+
func hello() {
|
184
102
|
|
185
|
-
|
186
|
-
|
187
|
-
|
103
|
+
print("hello")
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
104
|
|
193
105
|
}
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
//Appleのサインイン状態の確認
|
198
|
-
|
199
|
-
@objc func handleASCredential() {
|
200
|
-
|
201
|
-
let userID = UserDefaults.standard.string(forKey: "userID")
|
202
|
-
|
203
|
-
print("userIdは(userID)")
|
204
|
-
|
205
|
-
let appleIDProvider = ASAuthorizationAppleIDProvider()
|
206
|
-
|
207
|
-
appleIDProvider.getCredentialState(forUserID: userID!) { (credentialState, error) in
|
208
|
-
|
209
|
-
switch credentialState {
|
210
|
-
|
211
|
-
case .authorized:
|
212
|
-
|
213
|
-
print("user remain logged in, proceed to another view")
|
214
|
-
|
215
|
-
//self.performSegue(withIdentifier: "LoginToUserSegue", sender: nil)
|
216
|
-
|
217
|
-
case .revoked:
|
218
|
-
|
219
|
-
print("user logged in before but revoked")
|
220
|
-
|
221
|
-
self.appDelegate.goLoginViewConroller()
|
222
|
-
|
223
|
-
case .notFound:
|
224
|
-
|
225
|
-
print("user haven't log in before")
|
226
|
-
|
227
|
-
self.appDelegate.goLoginViewConroller()
|
228
|
-
|
229
|
-
default:
|
230
|
-
|
231
|
-
print("unknown state")
|
232
|
-
|
233
|
-
self.appDelegate.goLoginViewConroller()
|
234
|
-
|
235
|
-
}
|
236
|
-
|
237
|
-
}
|
238
|
-
|
239
|
-
}
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
106
|
|
245
107
|
}
|
246
108
|
|