【发布时间】:2016-09-08 23:18:39
【问题描述】:
以下代码曾经运行良好,我能够将多个值保存到 Firebase 记录。但是,自从升级到 Swift 3 (Xcode 8) 后,这不再有效。我现在收到以下错误:
*** Terminating app due to uncaught exception 'InvalidFirebaseData', reason: '(setValue:) Cannot store object of type _SwiftValue at mood. Can only store objects of type NSNumber, NSString, NSDictionary, and NSArray.'
上面的错误总是提到第二个值,不管它是什么类型(即使它是支持的类型之一,比如 NSString)。这是我所拥有的:
postsRef.childByAutoId().setValue(["postedBy": self.currentUser?.uid, "mood": mood, "status": status, "date": convertedDate])
这似乎仍然符合 Firebase 网站上的文档。我做错了什么?
谢谢!
【问题讨论】:
-
mood是什么类型,你在哪里以及如何声明的?
标签: ios swift firebase firebase-realtime-database swift3