附加数组值后为空

时间:2018-07-26 09:29:48

标签: ios swift

我正在从Firebase获取数据并将其存储到Firebase中。 追加后,当我调用该数组时,其显示为空

    var GetUseruiD = [String]()
    this is my firebase appending data to array 
     self.userDataRef = GlobalUserData.shared.getUserDataReference()
                    .child(Constants.FLAT_Visitor).child(userUID)
                self.userDataRef?.observeSingleEvent(of: .value, with: {(snapshot) in
                    if snapshot.childrenCount > 0 {
                        for users in snapshot.children.allObjects as! [DataSnapshot] {
                            GetUseruiD.append(users.key)
                            print("GetUseruiD is  ",GetUseruiD)
                        }
                    }
                })

     print("GetUseruiD is  ",GetUseruiD)

    if am print the values is am getting err but inside Getuse
GetUseruiD is outside   []
GetUseruiD is inside    ["-LIK5CNBk0vKS_Tto64E"]
GetUseruiD is inside    ["-LIK5CNBk0vKS_Tto64E", "-LIK5UbOBCQalyoqmQ-E"]

0 个答案:

没有答案