Reputation: 1678
What is the Swift5 Syntax for Parse PFObject saveInBackground progressBlock? I get error "Incorrect argument labels in call (have _:progressBlock, expected withTarget:selector). The Parse documentation appears not up to date. Thanks in advance for any advice.
let imageData = image.pngData()!
let imageFileObject = PFFileObject(name: "image.png", data: imageData)
let userPhoto = PFObject(className: "ARReferenceImages")
userPhoto["imageName"] = "Test 1"
userPhoto["imageFileObject"] = imageFileObject
userPhoto.saveInBackground ({ (success: Bool, error: Error?) in // Xcode error here
if (success) {
print("image saved to cloud")
} else if error != nil {
print("error saving data to cloud")
}
}, progressBlock: { (percentDone: Int32) in
// code to update progress bar spinner here
})
Upvotes: 0
Views: 61
Reputation: 2984
PFObject
does not have progressBlock
. PFFile
is the one that has. You should use it like this:
let imageData = image.pngData()!
let imageFileObject = PFFileObject(name: "image.png", data: imageData)
imageFileObject.saveInBackground ({ (success: Bool, error: Error?) in // Xcode error here
if (success) {
let userPhoto = PFObject(className: "ARReferenceImages")
userPhoto["imageName"] = "Test 1"
userPhoto["imageFileObject"] = imageFileObject
userPhoto.saveInBackground { (succeeded, error) in
if (succeeded) {
// The object has been saved.
} else {
// There was a problem, check error.description
}
}
} else if error != nil {
print("error saving data to cloud")
}
}, progressBlock: { (percentDone: Int32) in
// code to update progress bar spinner here
})
Upvotes: 1