gpt4 book ai didi

ios - 删除单行解析

转载 作者:行者123 更新时间:2023-11-30 14:11:56 26 4
gpt4 key购买 nike

我正在尝试从 Parse 中删除一行,但我不知道该怎么做。我有一个 tableView,上面有一些从 Parse 中获取的名称,当我使用 commitEditingStyle 函数时,我想从 Parse 中删除该名称。我写了这段代码,但它不完整,我不知道如何完成它:

if (editingStyle == UITableViewCellEditingStyle.Delete) {
var friendSelected:String = friendsArray[indexPath.row]
friendsArray.removeAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
// Remove From Parse

var tempArrayFriend:[String] = [String]()

var query = PFQuery(className:"Friend")
query.whereKey("UserKey", containsString: PFUser.currentUser()?.username)

query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in

for friend in objects! {
let friendFromParse:String? = (friend as! PFObject)["Friend"] as? String
// Aggiungo i voti all'array corrispondete
if friendFromParse != nil {

tempArrayFriend.append(friendFromParse!)

friend.removeObjectForKey(friendSelected)

} else {
// Log details of the failure
}
}
}

我想从 Parse 中删除一行,其中键是 PFUser.username!谢谢您,希望您能帮助我!

最佳答案

我认为你让事情变得比需要的复杂得多。试试这个:

if (editingStyle == UITableViewCellEditingStyle.Delete) {
var friendSelected:String = friendsArray[indexPath.row]
friendsArray.removeAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
// Remove From Parse


var query = PFQuery(className:"Friend")
query.whereKey("UserKey", containsString: PFUser.currentUser()?.username)

query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
for friend in objects! {
friend.deleteInBackgroundWithBlock(nil)
}
} else {
// Log details of the failure
}
}
}

关于ios - 删除单行解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31677890/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com