質問編集履歴
7
文章を修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -24,6 +24,7 @@
|
|
24
24
|
REF_POSTS.child("posts").observe(.childAdded, with: { (DataSnapshot) in
|
25
25
|
```
|
26
26
|
で、Firebaseにアクセスできていないことが原因ではないかと考えています。
|
27
|
+
書き直した前後で書き方を変えていないが、APIのファイルではうまくいきません。
|
27
28
|
しかし、解決策がわかりません。
|
28
29
|
|
29
30
|
###Runした際の画面表示
|
6
文章を修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
##問題
|
8
8
|
書き直す前: Firebaseにアクセス成功
|
9
|
-
書き直した後: Firebaseにアクセスできない?
|
9
|
+
書き直した後: Firebaseにアクセスできない?から、indicatorがずっと回ったままの状態になる
|
10
10
|
書き直し後のconsole: エラーなし ↓
|
11
11
|
```console
|
12
12
|
2018-11-30 14:53:34.637882+0900 aaabbbccc[34977:1806460] - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
|
5
書式の改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,6 +32,7 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
###コード
|
35
|
+
書き直す前
|
35
36
|
```controller
|
36
37
|
func loadPost() {
|
37
38
|
activityIndicatorView.startAnimating()
|
@@ -48,6 +49,19 @@
|
|
48
49
|
})
|
49
50
|
}
|
50
51
|
```
|
52
|
+
書き直した後
|
53
|
+
```controller
|
54
|
+
func loadPost() {
|
55
|
+
PostApi().observePosts { (Post) in
|
56
|
+
self.fetchUser(uid: Post.uid!, completed: {
|
57
|
+
self.posts.append(Post)
|
58
|
+
self.activityIndicatorView.stopAnimating()
|
59
|
+
self.activityIndicatorView.isHidden = true
|
60
|
+
self.tableView.reloadData()
|
61
|
+
})
|
62
|
+
}
|
63
|
+
}
|
64
|
+
```
|
51
65
|
```Api
|
52
66
|
class PostApi {
|
53
67
|
var REF_POSTS = Database.database().reference().child("posts")
|
4
文章の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -30,6 +30,41 @@
|
|
30
30
|
(indicatorが回ったまま止まっています。)
|
31
31
|

|
32
32
|
|
33
|
+
|
34
|
+
###コード
|
35
|
+
```controller
|
36
|
+
func loadPost() {
|
37
|
+
activityIndicatorView.startAnimating()
|
38
|
+
Database.database().reference().child("posts").observe(.childAdded, with: { (DataSnapshot) in
|
39
|
+
if let dict = DataSnapshot.value as? [String: Any] {
|
40
|
+
let newPost = Post.transformPostPhoto(dict: dict, key: DataSnapshot.key)
|
41
|
+
self.fetchUser(uid: newPost.uid!, completed: {
|
42
|
+
self.posts.append(newPost)
|
43
|
+
self.activityIndicatorView.stopAnimating()
|
44
|
+
self.activityIndicatorView.isHidden = true
|
45
|
+
self.tableView.reloadData()
|
46
|
+
})
|
47
|
+
}
|
48
|
+
})
|
49
|
+
}
|
50
|
+
```
|
51
|
+
```Api
|
52
|
+
class PostApi {
|
53
|
+
var REF_POSTS = Database.database().reference().child("posts")
|
54
|
+
|
55
|
+
func observePosts(complition: @escaping (Post) -> Void) {
|
56
|
+
print("1----------")
|
57
|
+
REF_POSTS.child("posts").observe(.childAdded, with: { (DataSnapshot) in
|
58
|
+
print("2--------")
|
59
|
+
print(DataSnapshot.value)
|
60
|
+
if let dict = DataSnapshot.value as? [String: Any] {
|
61
|
+
let newPost = Post.transformPostPhoto(dict: dict, key: DataSnapshot.key)
|
62
|
+
complition(newPost)
|
63
|
+
}
|
64
|
+
})
|
65
|
+
}
|
66
|
+
```
|
67
|
+
|
33
68
|
すみませんが、よろしくお願いします。
|
34
69
|
|
35
70
|
##開発環境
|
3
書式の改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,8 +5,8 @@
|
|
5
5
|

|
6
6
|
|
7
7
|
##問題
|
8
|
-
書き直す前: Firebaseアクセス成功
|
8
|
+
書き直す前: Firebaseにアクセス成功
|
9
|
-
書き直した後: Firebaseアクセス
|
9
|
+
書き直した後: Firebaseにアクセスできない?
|
10
10
|
書き直し後のconsole: エラーなし ↓
|
11
11
|
```console
|
12
12
|
2018-11-30 14:53:34.637882+0900 aaabbbccc[34977:1806460] - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
|
@@ -25,6 +25,11 @@
|
|
25
25
|
```
|
26
26
|
で、Firebaseにアクセスできていないことが原因ではないかと考えています。
|
27
27
|
しかし、解決策がわかりません。
|
28
|
+
|
29
|
+
###Runした際の画面表示
|
30
|
+
(indicatorが回ったまま止まっています。)
|
31
|
+

|
32
|
+
|
28
33
|
すみませんが、よろしくお願いします。
|
29
34
|
|
30
35
|
##開発環境
|
2
画像の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
##やりたいこと
|
2
2
|
Apiを作って、コードを簡潔に書きたい
|
3
3
|

|
4
|
-

|
5
5
|

|
6
6
|
|
7
7
|
##問題
|
1
タイトルの修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Firebaseにアクセスできない?
|
1
|
+
Swift・iOSアプリで、Firebaseにアクセスできない?
|
body
CHANGED
File without changes
|