[英]ClosedRange Firebase Swift read & write
I am using a Closed range eg let ageRange = ClosedRange(18...45) 我正在使用封闭范围,例如让ageRange = ClosedRange(18 ... 45)
What is the best way of saving this to Firebase DB? 将其保存到Firebase DB的最佳方法是什么? Do I need to save the lower and upper bound separately?
我需要分别保存上下限吗?
Thanks 谢谢
The Firebase Database can only store JSON types. Firebase数据库只能存储JSON类型。
Since ClosedRange
is not a JSON type, you'll have to find a way to convert it back and forth. 由于
ClosedRange
不是JSON类型,因此您必须找到一种来回转换的方法。
Two common ways to do this: 两种常见的方法可以这样做:
The first one is often easiest. 第一个通常是最简单的。 But the second option has the advantage that you can query for its parts.
但是第二种选择的优点是您可以查询其零件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.