Swift Parse progressBlock: extra argument in call

269 views Asked by At

The error says: extra argument 'progressBlock' in call. What's wrong?

pin.saveInBackgroundWithBlock({(success, error) -> Void in
    if success == false {
        ...
     } else {
          ...
      }

  },
    progressBlock: { (amountDone: CInt) -> Void in
        var percent = Float(amountDone)
        elf.progressIndicatorView.progress = CGFloat(percent)/100

        self.progressIndicatorView.reveal()

  })
2

There are 2 answers

1
Juan Carlos Ospina Gonzalez On

try:

 pin.saveInBackgroundWithBlock({ (succeeded: Bool, error: NSError?) -> Void in
    // Handle success or failure here ...
    if succeeded {
        println("Save successful")
    } else {
        println("Save unsuccessful: \(error?.userInfo)")
    }

    }, progressBlock: { (amountDone: Int32) -> Void in
          var percent = Float(amountDone)
          self.progressIndicatorView.progress = CGFloat(percent)/100
          self.progressIndicatorView.reveal()
})
0
Arpit On

Lots of changes to Swift syntax in the last few years. Here is what seems to work in 2018

file!.saveInBackground({ (_ didSucceed:Bool, err:Error?) in
                print("success: \(didSucceed)")
            }) { (progress:Int32) in
                print("progress: \(progress)")
            }