gpt4 book ai didi

xcode - 如何使解析查询同步快速

转载 作者:搜寻专家 更新时间:2023-11-01 06:47:07 25 4
gpt4 key购买 nike

有什么方法可以使解析查询同步吗?我尝试将查询更改为 findObjects 而不是 findObjectsInBackgroundWithBlock。我似乎无法弄清楚它的语法。有人可以帮我解决这个问题吗?任何帮助表示赞赏。谢谢。

    var messageQuery = PFQuery(className: "Message")

messageQuery.whereKey("GUID", equalTo: GUID)



messageQuery.findObjectsInBackgroundWithBlock {

(objects: [AnyObject]!, error: NSError!) -> Void in

if error == nil {

// The find succeeded.
println("Successfully retrieved \(objects.count) scores.")

// Do something with the found objects
if let objects = objects as? [PFObject] {

for object in objects {

println("in loop of objects retrieved")
object.delete()

}

}

messages.removeAtIndex(messageIndex)
//objectIDArr.removeAtIndex(messageIndex)

}else {

// Log details of the failure
println("Error: \(error) \(error.userInfo!)")

}

}

最佳答案

您可以调用 findObjects 方法,它返回一个 NSArray。 See the reference on parse

例如:

PFQuery query = PFQuery(classname: "Message")
query.whereKey("GUID", equalTo: GUID)
NSArray messages = query.findObjects()
for message in messages {
//do whatever you want with your message object
}

关于xcode - 如何使解析查询同步快速,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29360566/

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