You have to convert your UserModel
to [String : Any]
type in order to save it on firebase. Try this:
func convertUserModelToDictionary(user: UserModel) -> [String : Any] {
let userData = [
"name" : user.name, // change these according to you model
"email": user.email,
"user_id": user.userId
]
return userData
}
You can use this function as:
do {
let userData = convertUserModelToDictionary(user: userInfo)
try db.collection("usersInformations").document(userInfo.id).setData(from: userData)
} catch let error {
print(error.localizedDescription)
}
2
solved iOS Error: Cannot convert value of type ‘UserModel’ to expected argument type ‘[String : Any]’