我最近更新了Firebase吊舱,现在收到此错误:第二行代码的“用于条件绑定的初始化程序必须具有可选类型,而不是'String'“。
storageRef.downloadURL { (url, error) in
guard let url = url, let profileImageUrl = url.absoluteString else { return }
let values = ["name": name, "email": email, "profileImageUrl": profileImageUrl]
self.registerUserIntoDatabaseWithUID(uid: uid, values: values as [String: AnyObject])
}
答案 0 :(得分:0)
请⌥-单击在可选绑定表达式中的参数上,您将看到absoluteString
被声明为非可选。错误消息指出,不能将非可选内容绑定为条件。
仅绑定url
,然后在absoluteString
中添加values
:
storageRef.downloadURL { (url, error) in
guard let url = url else { return }
let values = ["name": name, "email": email, "profileImageUrl": url.absoluteString]
self.registerUserIntoDatabaseWithUID(uid: uid, values: values as [String: AnyObject])
}