Frozensea
Frozensea

Reputation: 23

How to fix "Cannot convert value of type '(CGFloat) -> Data?' to expected argument type 'Data'" error on this code?

I tried to get image info for UIImage and then put them it through PFFile. But there is the below error on Xcode.

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

let imageData = UIImage.jpegData(imageView.image!)

let file = PFFile(name: "320.jpg", data: imageData)

The error message is

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

Upvotes: 1

Views: 757

Answers (1)

steveSarsawa
steveSarsawa

Reputation: 1679

Try this

let image = UIImage(named: "320.jpg")
let file = PFFile(data: image.jpegData(compressionQuality: 1.0))

Upvotes: 2

Related Questions