Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 从新Firebase(数据库)检索数据_Xcode_Swift_Firebase_Firebase Realtime Database - Fatal编程技术网

Xcode 从新Firebase(数据库)检索数据

Xcode 从新Firebase(数据库)检索数据,xcode,swift,firebase,firebase-realtime-database,Xcode,Swift,Firebase,Firebase Realtime Database,我无法从新Firebase检索数据。在我按下按钮(act())后,没有任何变化。我检查了Firebase网站上的所有设置并阅读了所有文档,但我不明白为什么什么都没发生 import UIKit import Firebase var ref = FIRDatabaseReference.init() class MainTovarViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDa

我无法从新Firebase检索数据。在我按下按钮(act())后,没有任何变化。我检查了Firebase网站上的所有设置并阅读了所有文档,但我不明白为什么什么都没发生

    import UIKit
import Firebase

var ref = FIRDatabaseReference.init()

class MainTovarViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
@IBOutlet weak var collectionView: UICollectionView!
var items = [FIRDataSnapshot]()
override func viewDidAppear(animated: Bool) {

}
override func viewDidLoad() {
    super.viewDidLoad()
    ref = FIRDatabase.database().reference()

}


@IBAction func act(sender: AnyObject) {
    ref.observeEventType(FIRDataEventType.Value) { (snapshot: FIRDataSnapshot!) in

        var newItems = [FIRDataSnapshot]()
        for item in snapshot.children {
            newItems.append(item as! FIRDataSnapshot)
        }

        self.items = newItems
        print("\(self.items)")
        self.collectionView!.reloadData()
    }
}
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    var result = 0
    if items.count != 0 {
        result = items.count
    }
    return result
}

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier("MainTovarCollectionCell", forIndexPath: indexPath) as! MainTovarCollectionCellCollectionViewCell
    cell.backgroundView = UIImageView(image: UIImage(named: "product_1"))
    cell.titletovar.text = items[indexPath.row].value!.objectForKey("TovarName") as! String

    return cell
}

}
这是:

2016-05-21 10:55:38.340 shoroo[95390:14237917] WARNING: Firebase 

Analytics App Delegate Proxy is disabled. To log deep link campaigns manually, call the methods in FIRAnalytics+AppDelegate.h.
2016-05-21 10:55:38.510 shoroo[95390:14237917] Configuring the default app.
2016-05-21 10:55:38.522 shoroo[95390:] <FIRAnalytics/INFO> Firebase Analytics v.3200000 started
2016-05-21 10:55:38.523 shoroo[95390:] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2016-05-21 10:55:38.529: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"
2016-05-21 10:55:38.533: <FIRMessaging/INFO> FIRMessaging library version 1.1.0
2016-05-21 10:55:38.564 shoroo[95390:] <FIRAnalytics/INFO> Firebase Analytics enabled
Error Domain=NSCocoaErrorDomain Code=3010 "REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION" UserInfo={NSLocalizedDescription=REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION}
2016-05-21 10:55:38.340 shoroo[95390:14237917]警告:Firebase
分析应用程序代理已禁用。要手动记录深度链接活动,请调用FIRAnalytics+AppDelegate.h中的方法。
2016-05-21 10:55:38.510 shoroo[95390:14237917]配置默认应用程序。
2016-05-21 10:55:38.522 shoroo[95390:]Firebase Analytics v.3200000启动
2016-05-21 10:55:38.523 shoroo[95390:]要启用调试日志记录,请设置以下应用程序参数:-FIRAnalyticsDebugEnabled
2016-05-21 10:55:38.529:无法获取APNS令牌错误域=com.firebase.iid代码=1001“(空)”
2016-05-21 10:55:38.533:FIRMessaging库版本1.1.0
2016-05-21 10:55:38.564 shoroo[95390:]启用Firebase分析
Error Domain=NSCOCAERRORDOMAIN Code=3010“远程\u通知\u模拟器\u不受支持\u错误\u说明”用户信息={NSLocalizedDescription=REMOTE\u通知\u模拟器\u不受支持\u错误\u说明}

检查您的数据库授权(规则)。尝试将规则设置为:

{
  "rules": {
    ".read": true,
    ".write": true
  }
}

是否将FIRApp.configure()包含在应用程序:didFinishLaunchingWithOptions:method中?此外,您可能应该使用self.ref,而不仅仅是ref。最后一件事是您的pod文件可能没有正确配置,因此分析没有链接到您的项目中。看,你在使用代理吗?看见