Firebase swift - 无法将'FIRUserInfoImpl'类型的值转换为'NSDictionary'

时间:2016-06-15 09:46:07

标签: swift firebase firebase-realtime-database firebase-authentication

我有一个facebook和twitter登录按钮。我关注user guide。我想存储用户信息但是我收到此错误Could not cast value of type 'FIRUserInfoImpl' to 'NSDictionary'

我不知道为什么我无法存储相关数据。那是因为提供者数据与对象类型不匹配吗?

func createFirebaseUser(){

        //MARK: Assign what to get from current User data.
        let key = ref.child("users").childByAutoId().key
        if let user = FIRAuth.auth()?.currentUser{
        for profile in user.providerData {
        let userID = profile.uid as! String!
        let username = profile.displayName as! String!
        let email = profile.email as! String!
        let profilePicUrl = profile.photoURL as! NSURL!


        ref.child("users").updateChildValues(profile as? NSDictionary as! [NSObject : AnyObject])

        }
        }

1 个答案:

答案 0 :(得分:0)

您应该创建一个字典以使用updateChildValues发送数据。