简体   繁体   中英

How to fix “Extra argument in call” error in Swift

I am new to coding and am trying to have a selected image stored but it has an error saying "Extra argument in call." I'm not too sure what this means. What do I need to do? Thank you in advance!

@IBAction func shareButton_TouchUpInside(_ sender: Any) {
    view.endEditing(true)
    ProgressHUD.show("Waiting...", interaction: false)
    if let profileImg = self.selectedImage, let imageData = **selectedImage?.jpegData(profileImg, 0.1) {**
        let photoIdString = NSUUID().uuidString
        let storageRef = Storage.storage().reference(forURL: Config.STORAGE_ROOF_REF).child("posts").child(photoIdString)

If you see the code

selectedImage?.jpegData(profileImg, 0.1)

you are passing two arguments. But, UIImage function, it takes only one argument which is the compressionQuality

func jpegData(compressionQuality: CGFloat) -> Data?

"Extra argument in call" usually occurs when you pass incorrect parameters. jpedData accepts compressionQuality param.

Instead of selectedImage?.jpegData(profileImg, 0.1)

Try

selectedImage?.jpegData(compressionQuality: 0.1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM