所以我有两个问题:
nil
。这里有一些代码段:
//MARK: - Make Object
func makeObjectPost(title: String, imageTitle: UIImage, content: [String: AnyObject]) {
//Make a new post object
let postObject = PostModel()
postObject.title = title
postObject.imageTitle = returningImageData(image: imageTitle)
postObject.content = content
//Save the new object to firebase
postObject.save { (ref, error) in
if error != nil {
print(error?.localizedDescription)
}
}
}
makeObjectPost(title: "Third Post", imageTitle: #imageLiteral(resourceName: "william-iven-19844"), content: makeContentDict(contentPost: currPost))
答案 0 :(得分:0)
首先,我认为将存储扩展名(例如.jpeg)的图像存储为更好的做法。 因此,当您将新对象保存到数据库时,会存储图像名称。 要获得图像,请尝试使用以下内容:
let yourImageRef = FIRStorage.storage().reference(withPath: "someStartingPart/images").child(yourObject.imageTitle + ".jpeg")
yourImageRef.downloadURL { (URL, error) in
// do everything you want
}