如何从此快照中检索senderId
。必须使用ChildAdded
,并且下面的FirRef必须保持不变。
这是我当前用于从firebase检索数据的函数
func retrieveInfo(completion: (result: String)->()) {
fireBaseAPI().childRef("version_one/frontEnd/post/\(self.previousViewMessageId)").observeEventType(.ChildAdded, withBlock: {snapshot in
})
这是正在打印的快照
Snap (postDescription) Description here
Snap (postTitle) What do you need done
Snap (receiverId) RYclS9Qy4vRr6gp8JbfoztSYQnL2
Snap (senderId) niZKOcnoh0cdFpF2K26bxugw1hz1
Snap (status) 0
Snap (messages) {
"-KRqOqd2POJYpCNSSumG" = {
mediaType = TEXT;
senderDisplayName = "";
senderId = niZKOcnoh0cdFpF2K26bxugw1hz1;
text = iPhone;
};
}
检索任何显示Snap
的节点的最佳方法是什么这是firebase Json
{
"version_one" : {
"frontEnd" : {
"post" : {
"-KRoucvwAs1jBaoNahDP" : {
"messages" : {
"-KRqOqd2POJYpCNSSumG" : {
"mediaType" : "TEXT",
"senderDisplayName" : "",
"senderId" : "niZKOcnoh0cdFpF2K26bxugw1hz1",
"text" : "iPhone"
}
},
"postDescription" : "Description here",
"postTitle" : "What do you need done",
"receiverId" : "RYclS9Qy4vRr6gp8JbfoztSYQnL2",
"senderId" : "niZKOcnoh0cdFpF2K26bxugw1hz1",
"status" : 0
}
},
答案 0 :(得分:1)
func printname(sender: UIButton) {
// ...
}