Swift 一次删除多个对象解析服务器
Swift Delete multiple objects at once Parse server
我向服务器查询
let query = PFQuery(className: "posts")
query.whereKey("uuid", equalTo: Ncell.uuidLbl.text!)
query.findObjectsInBackground { (objects:[PFObject]?, error:Error?) in
if error == nil {
for object in objects! {
object.deleteInBackground(block: { (success:Bool, error:Error?) in
if success{
}
})
}
}
}
我想知道是否可以一次删除所有找到的对象以节省请求,而不是使用循环并单独删除每个对象。
I want to know if it would be possible to delete all the found objects at once
是在Parse iOS SDK to delete multiple objects in background at once on Parse server, you can use deleteAllInBackground
您可以通过两种不同的方式使用它:
PFObject.deleteAll(inBackground: [PFObject]?)
PFObject.deleteAll(inBackground: [PFObject]?, block: PFBooleanResultBlock?)
例如:
let query = PFQuery(className: "posts")
query.whereKey("uuid", equalTo: Ncell.uuidLbl.text!)
query.findObjectsInBackground { (objects:[PFObject]?, error:Error?) in
if error == nil {
PFObject.deleteAll(inBackground: objects, block: { (success:Bool, error:Error?) in
if success {
}
})
}
}
希望我的回答对您有所帮助
我向服务器查询
let query = PFQuery(className: "posts")
query.whereKey("uuid", equalTo: Ncell.uuidLbl.text!)
query.findObjectsInBackground { (objects:[PFObject]?, error:Error?) in
if error == nil {
for object in objects! {
object.deleteInBackground(block: { (success:Bool, error:Error?) in
if success{
}
})
}
}
}
我想知道是否可以一次删除所有找到的对象以节省请求,而不是使用循环并单独删除每个对象。
I want to know if it would be possible to delete all the found objects at once
是在Parse iOS SDK to delete multiple objects in background at once on Parse server, you can use deleteAllInBackground
您可以通过两种不同的方式使用它:
PFObject.deleteAll(inBackground: [PFObject]?)
PFObject.deleteAll(inBackground: [PFObject]?, block: PFBooleanResultBlock?)
例如:
let query = PFQuery(className: "posts")
query.whereKey("uuid", equalTo: Ncell.uuidLbl.text!)
query.findObjectsInBackground { (objects:[PFObject]?, error:Error?) in
if error == nil {
PFObject.deleteAll(inBackground: objects, block: { (success:Bool, error:Error?) in
if success {
}
})
}
}
希望我的回答对您有所帮助