私のコードに何か問題があると思われますが、私がここで間違っていることを特定することはできません。この行のエラーは、私のsignUp関数内にあるself.setUserInfo(firstLastName: firstLastName, user: user, username: username, location: location, biography: biography, password: password, pictureData: pictureData)
です。タイプ「User?」の値を変換できません。期待される引数型 'User!'
タイプ 'User'の値を変換できません。期待される引数型 'User!' あなたが使用してユーザー・パラメータの開封された値を設定したsetUserInfo方法で
func signUP(firstLastName: String, username: String, email: String, location: String, biography: String, password: String, pictureData: NSData!) {
Auth.auth().createUser(withEmail: email, password: password) { (user, error) in
if error == nil{
self.setUserInfo(firstLastName: firstLastName, user: user, username: username, location: location, biography: biography, password: password, pictureData: pictureData)
}else{
print(error?.localizedDescription)
}
}
}
private func setUserInfo(firstLastName: String, user: User!, username: String, location: String, biography: String, password: String, pictureData: NSData!){
let imagePath = "profileImage\(user.uid)/userPic.jpg"
let imageRef = storageRef.child(imagePath)
let metaData = StorageMetadata()
metaData.contentType = "image/jpeg"
imageRef.putData(pictureData as Data, metadata: metaData){(newMetaData, error)
in
if error == nil{
let changeRequest = User.createProfileChangeRequest()
changeRequest.displayName = username
if let photoURL = newMetaData!.downloadURL(){
changeRequest.photoURL = photoURL
}
changeRequest.commitChanges(completion: { (error) in
if error == nil{
self.saveUserInfo(firstLastName: firstLastName, user: user, username: username, location: location, biography: biography, password: password)
print("user info set")
}else{
print(error?.localizedDescription)
}
})
}else{
print(error?.localizedDescription)
}
}
}
ショーの実装:'メソッド – D4ttatraya
自分のUserクラスを見て何これは、これがもたらしたユーザーパラメータ – Torewin