// Log user inif let user = FIRAuth.auth()?.currentUser { let uID = user.uID // values for vars sevendaysAgo and oneDayAgo set here ... let historyRef = self.ref.child("historyForFeedbackLoop/\(uID)") historyRef.queryOrdered(byChild: "Unix Date").queryStarting(atValue: sevendaysAgo).queryEnding(atValue: oneDayAgo).observeSingleEvent(of: .value,with: { snapshot in if (snapshot.value is NSNull) { print("user data not found") } else { if let snapDict = snapshot.value as? [String:AnyObject] { for each in snapDict { // Save the IDs to array. let uniqueID = each.value["Unique ID Event Number"] as! Int self.arrayOfUserSearchHistoryIDs.append(uniqueID) } } else{ print("SnapDict is null") } } })}
我尝试应用我从这个post中学到的东西,但我无法弄清楚我错过了什么,因为我以为我让编译器知道它是什么类型的字典“as?[String:AnyObject]”
任何想法或想法将不胜感激!
我处理数据的首选方法是尽可能晚地打开FIRDataSnapshot.ref!.observe(.value,with: { (snapshot) in for child in snapshot.children { let msg = child as! FIRDataSnapshot print("\(msg.key): \(msg.value!)") let val = msg.value! as! [String:Any] print("\(val["name"]!): \(val["message"]!)") }})总结
以上是内存溢出为你收集整理的下标的模糊使用(Swift 3)全部内容,希望文章能够帮你解决下标的模糊使用(Swift 3)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)