无法转换“() -> 数据类型的值?”到预期的参数类型 'Data'

Cannot convert value of type '() -> Data?' to expected argument type 'Data'

if let imageData = UIImage.pngData(image) {
    let imageFile = PFFile(name: "image.png", data: imageData)
    post["imageFile"] = imageFile
    post.saveInBackground { (success, error) in
    }
}

此代码一直显示错误:

Cannot convert value of type '() -> Data?' to expected argument type 'Data'

我以为 UIImage.pngData 只是 return Data? 的值类型。

你的第一行不正确。您需要在 UIImage 实例上调用 pngData

if let imageData = image.pngData() {