1
페이스 북과 트위터 로그인 버튼이 있습니다. 나는 user guide을 따른다. 사용자 정보를 저장하고 싶지만이 오류가 나타납니다. Could not cast value of type 'FIRUserInfoImpl' to 'NSDictionary'
Firebase swift - 'FIRUserInfoImpl'유형의 값을 '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])
}
}
'profile'은'FIRUserInfo' 타입이고, 사전에 캐스팅 될 수 없습니다. 그것이 오류 메시지가 말하는 것입니다. 어쩌면 추출 된 속성으로 사전을 만들어야 할 수도 있습니다. 그리고'String! '과'NSURL!'에있는 모든 느낌표를 삭제하십시오. 당신은 분명히 비 선택적인 것을 원한다. – vadian
데이터 모델을 만드시겠습니까? –
'updateChildValues' 매개 변수의 유형과 일치하는 것을 만드십시오 – vadian