本文介绍了如何在Swift中包含服务器端的时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在firebase改进之前,我可以在任何结构中发布时间戳,如
$ b $ pre $ let usmsg = [CreatedAt:FirebaseServerValue.timestamp( ),ChatTitle:msg.ChatTitle,ChatBody:msg.ChatBody,Owner:self.GoogleUserID]

但后 FIRServerValue.timestamp()成为( NSDictionary * )我无法获得时间戳作为数据库的一个值。

解决方案

尝试 [CreatedAt:[.sv: timestamp] ...]

该键的保存值必须是这样的:1464103942351


Before firebase improvements I could post timestamps in any struct like

let usermsg =  ["CreatedAt":FirebaseServerValue.timestamp(), "ChatTitle":msg.ChatTitle,"ChatBody":msg.ChatBody,  "Owner":self.GoogleUserID]

But after FIRServerValue.timestamp() became ( NSDictionary *) I could not get timestamp to post as a value to the database.

解决方案

Try ["CreatedAt": [".sv": "timestamp"]...]
The saved value for that key must be something like: 1464103942351

这篇关于如何在Swift中包含服务器端的时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 22:14