请求结果结构firebasedatabase Swift [英] Request result structure firebasedatabase Swift

查看:79
本文介绍了请求结果结构firebasedatabase Swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了像我在Java中一样迅速地从快照中检索自定义类的值,我使用Firebasedecoder.工作正常,但我需要以下结构

Looking to retrieve value of custom class from a snap in swift like i do in java , i use Firebasedecoder . Works fine but i need the following structure

{

username = uiii;
email = test@rom.com

..}

如果我发出诸如 .queryOrdered(ByCHild:email).queryEqual("uiii")之类的有序请求,我将获得前一个节点的请求:

If i make ordered requests like .queryOrdered(ByCHild:email).queryEqual("uiii"), i get the resquest with a previous node :

{

"hjhj"= {
username = uiii;
email = test@rom.com

..} }

寻找一种方法来删除不必要的值或具有正确的快照结构.

Looking for a way to either remove the uneccessary values or to have the correct snap structure.

推荐答案

简而言之,如果您具有相同级别的额外数据,并且导致 decodeFirebase 崩溃,您仍然可以使用它:

In short, if you have extra data at the same level and that makes decodeFirebase crash, you still can use it:

let value = snapshot.value 
let modifiedValue:NSMutableDictionary = (value as AnyObject).mutableCopy() as! MutableDictionary

然后您可以通过以下键删除元素: modifiedValue.removeObject(forKey:test)然后应用解码.

You then can remove elements by key: modifiedValue.removeObject(forKey: test) and then apply decode.

这篇关于请求结果结构firebasedatabase Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆