我已经尝试了一切,但我无法弄清楚错误。
import Foundation
import Firebase
struct User {
var email: String!
var firstname: String
var lastname: String
var uid: String!
var profilePictureUrl: String
var country: String
var ref: FIRDatabaseReference!
var key: String = ""
init(email: String, firstname: String, lastname: String, uid: String, profilePictureUrl: String, country: String) {
self.email = email
self.firstname = firstname
self.lastname = lastname
self.profilePictureUrl = profilePictureUrl
self.country = country
self.ref = FIRDatabase.database().reference()
}
func toAnyObject() -> [String: Any] {
return ["email": email, "firstname": firstname, "lastname": lastname, "country": country, "uid": uid, "profilePictureUrl": profilePictureUrl]
}
}
错误在函数toAnyObject
中。
答案 0 :(得分:-1)
你的函数返回[String:Any]。但是,它的值不是Any。可以像以下一样简单地进行编辑。
func toAnyObject() -> [String: Any] {
return ["email": email, "firstname": firstname, "lastname": lastname, "country": country, "uid": uid, "profilePictureUrl": profilePictureUrl] as [String : Any]
希望它可以帮助您修复问题。