PFObject saveInBackground progressBlock 的语法
Syntax for PFObject saveInBackground progressBlock
Parse PFObject saveInBackground progressBlock 的 Swift5 语法是什么?我收到错误消息“调用中的参数标签不正确(有 _:progressBlock,预计 withTarget:selector)。Parse 文档似乎不是最新的。在此先感谢您的任何建议。
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
})
PFObject
没有 progressBlock
。 PFFile
是有的。你应该这样使用它:
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
})
Parse PFObject saveInBackground progressBlock 的 Swift5 语法是什么?我收到错误消息“调用中的参数标签不正确(有 _:progressBlock,预计 withTarget:selector)。Parse 文档似乎不是最新的。在此先感谢您的任何建议。
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
})
PFObject
没有 progressBlock
。 PFFile
是有的。你应该这样使用它:
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
})