我刚刚更新到Swift 3
中的Xcode
,我无法弄清楚如何处理此错误。谁能帮忙???
错误: InvalidFirebaseData',原因:'(setValue :)无法在thumbnailUrlFromStorage 存储_SwiftValue类型的对象。只能存储NSNumber,NSString,NSDictionary和NSArray类型的对象。
我的代码是:
// Create a url for data (tumbnail image)
self.fileUrl = metaData?.downloadURLs![0].absoluteString
if (FIRAuth.auth()?.currentUser) != nil {
let idRoom = self.BASE_REF.child("rooms").childByAutoId()
idRoom.setValue(["caption": caption, "thumbnailUrlFromStorage": self.storageRef.child(metaData!.path!).description, "fileUrl": self.fileUrl])
答案 0 :(得分:2)
if (FIRAuth.auth()?.currentUser) != nil {
let idRoom = self.BASE_REF.child("rooms").childByAutoId()
let thumbnailUrlFromStorage: String = self.storageRef.child(metaData!.path!).description
let data: Dictionary<String, Any> = [
"caption": caption,
"thumbnailUrlFromStorage": thumbnailUrlFromStorage,
"fileUrl": self.fileUrl
]
idRoom.setValue(data)
}
不确定这是否可行,因为我没有机会运行它,但对我来说看起来你传递self.storageRef.child(metaData!.path!).description
为零。