Ios swift解析:查询后如何洗牌对象?

Ios swift解析:查询后如何洗牌对象?,ios,swift,parse-platform,Ios,Swift,Parse Platform,据我所知,parse中没有简单的随机查询函数。在我查询对象之后,有没有办法洗牌它们 query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in if (error == nil) { // shuffle objects here? PFObject.pinAllInBackground(objects, withName:"Card", bloc

据我所知,parse中没有简单的随机查询函数。在我查询对象之后,有没有办法洗牌它们

query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in

        if (error == nil) {
            // shuffle objects here?
            PFObject.pinAllInBackground(objects, withName:"Card", block: nil)
有什么想法吗? 谢谢

编辑: 我认为问题在另一个方面。 当我在建议帖子中添加like(谢谢)这个洗牌扩展时,它的工作非常轻松

但是

如您所见,我将对象固定到本地存储

在下一个视图中,我再次从存储器中取出此数据:

var query = PFQuery(className: "Card")
query.fromLocalDatastore()
query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in

     if (error == nil){
        println("from local store: \(objects)")
在这里,我再次以相同的顺序将数据保存在数据库中。。。根本没有洗过的东西


这不是很奇怪吗?

只需获取对象并使用类似于在对象上提供的洗牌方法:

var shuffledObjects = shuffle(objects) 

可能重复:我认为问题在于,无论是从本地数据库还是解析数据库中提取它们,都会出现某种查询。我相信这默认按
updatedAt
排序。每次检索对象时都需要重新排序,然后在内存中排序。谢谢Logan!这似乎是一个正确的问题:(我认为没有办法阻止这种默认排序?
var shuffledObjects = shuffle(objects)