##問題
書き直す前: Firebaseにアクセス成功
書き直した後: Firebaseにアクセスできない?から、indicatorがずっと回ったままの状態になる
書き直し後のconsole: エラーなし ↓
console
12018-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 2objc[34977]: Class AXAccessQueue is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AccessibilityUtilities.framework/AccessibilityUtilities (0x13287f780) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/Accessibility.framework/Frameworks/AXHearingSupport.framework/AXHearingSupport (0x133b26888). One of the two will be used. Which one is undefined. 3objc[34977]: Class AXAccessQueueTimer is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AccessibilityUtilities.framework/AccessibilityUtilities (0x13287cd50) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/Accessibility.framework/Frameworks/AXHearingSupport.framework/AXHearingSupport (0x133b268d8). One of the two will be used. Which one is undefined. 42018-11-30 14:53:35.041256+0900 aaabbbccc[34977:1806372] [AXMediaCommon] Unable to look up screen scale 52018-11-30 14:53:35.041439+0900 aaabbbccc[34977:1806372] [AXMediaCommon] Unexpected physical screen orientation 62018-11-30 14:53:35.117602+0900 aaabbbccc[34977:1806372] [AXMediaCommon] Unable to look up screen scale 72018-11-30 14:53:35.126056+0900 aaabbbccc[34977:1806372] [AXMediaCommon] Unable to look up screen scale 82018-11-30 14:53:35.126208+0900 aaabbbccc[34977:1806372] [AXMediaCommon] Unexpected physical screen orientation 91----------
コンソールを見ると、書き直した後の
REF_POSTS.child("posts").observe(.childAdded, with: { (DataSnapshot) in
で、Firebaseにアクセスできていないことが原因ではないかと考えています。
書き直した前後で書き方を変えていないが、APIのファイルではうまくいきません。
しかし、解決策がわかりません。
###Runした際の画面表示
(indicatorが回ったまま止まっています。)
###コード
書き直す前
controller
1func loadPost() { 2 activityIndicatorView.startAnimating() 3 Database.database().reference().child("posts").observe(.childAdded, with: { (DataSnapshot) in 4 if let dict = DataSnapshot.value as? [String: Any] { 5 let newPost = Post.transformPostPhoto(dict: dict, key: DataSnapshot.key) 6 self.fetchUser(uid: newPost.uid!, completed: { 7 self.posts.append(newPost) 8 self.activityIndicatorView.stopAnimating() 9 self.activityIndicatorView.isHidden = true 10 self.tableView.reloadData() 11 }) 12 } 13 }) 14 }
書き直した後
controller
1func loadPost() { 2 PostApi().observePosts { (Post) in 3 self.fetchUser(uid: Post.uid!, completed: { 4 self.posts.append(Post) 5 self.activityIndicatorView.stopAnimating() 6 self.activityIndicatorView.isHidden = true 7 self.tableView.reloadData() 8 }) 9 } 10 }
Api
1class PostApi { 2 var REF_POSTS = Database.database().reference().child("posts") 3 4 func observePosts(complition: @escaping (Post) -> Void) { 5 print("1----------") 6 REF_POSTS.child("posts").observe(.childAdded, with: { (DataSnapshot) in 7 print("2--------") 8 print(DataSnapshot.value) 9 if let dict = DataSnapshot.value as? [String: Any] { 10 let newPost = Post.transformPostPhoto(dict: dict, key: DataSnapshot.key) 11 complition(newPost) 12 } 13 }) 14 }
すみませんが、よろしくお願いします。
##開発環境
MacOS Mojave 10.14.1
Xcode 10.0
Swift 3.0
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/30 07:46