Ambiguous Use of Subscript (Swift 3)

后端 未结 2 600
逝去的感伤
逝去的感伤 2020-12-12 06:11

I am using the subscript in the following code incorrectly for this Firebase data pull, but I can\'t figure out what I am doing wrong. I get an error of Ambiguous use of su

2条回答
  •  温柔的废话
    2020-12-12 06:27

    Taking Frank's feedback into account, here is the actual working code I used that follows that approach in case it's helpful.

    // Log user in
    if 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 {
    
                     for child in snapshot.children {
    
                        let data = child as! FIRDataSnapshot
                        let value = data.value! as! [String:Any]
                        self.arrayOfUserSearchHistoryIDs.append(value["Unique ID Event Number"] as! Int)
                     }
                }
       })
    }
    

提交回复
热议问题