【问题标题】:Swift: Use of unresolved identifier 'FDataSnapShot' when using firebase SDKSwift:使用 Firebase SDK 时使用未解析的标识符“FDataSnapShot”
【发布时间】:2016-06-09 04:15:17
【问题描述】:

我正在使用 swift 开发带有 firebase 的应用程序。 使用 FDataSnapShot 时出现错误。 这是我的代码。

    DataService.dataService.DATA_REF.observeEventType(.Value, withBlock: {
        snapshot in
        var newItems = [FDataSnapshot]()

        // loop through the children and append them to the new array
        for item in snapshot.children {
            newItems.append(item as! FDataSnapshot)
        }

        // replace the old array
        self.items = newItems
    })

我用 cocoapods 安装了 firebase sdk。 我的 pod 文件如下所示。

use_frameworks!

pod 'Firebase'
target 'nos' do
end

有人有这方面的经验吗? *注意:我使用的是最新版本的 Xcode(7.2)。 我真的希望很快能收到您的来信。

【问题讨论】:

  • 尝试在您的班级标题中添加import Firebase。另外,使用新的 Firebase CocoaPod 执行 ctrl+kctrl+b 清理缓存并重建项目
  • 对不起,它工作正常。
  • 我已经在应用委托中导入了 Firebase,但它不起作用。
  • 现在,我实现了“import Firebase”来查看控制器,它工作正常。谢谢。
  • @AntonKolya 如果这让您感到满意,我发布了答案。

标签: ios swift firebase


【解决方案1】:

如果您尝试在 UIViewController 上使用,请确保添加:

import Firebase

YourViewController,清理缓存 (ctrl+k),并在将 CocoaPod 添加到项目后重建 (ctrl+b)。

【讨论】:

    猜你喜欢
    • 2016-04-29
    • 1970-01-01
    • 2017-06-29
    • 2016-10-03
    • 2021-04-26
    • 2016-09-17
    • 2015-05-13
    • 2016-11-28
    • 2015-05-25
    相关资源
    最近更新 更多