Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Parse和Swift匹配PFObjects、获取计数并按降序显示对象?_Swift_Parse Platform_Count_Match - Fatal编程技术网

如何使用Parse和Swift匹配PFObjects、获取计数并按降序显示对象?

如何使用Parse和Swift匹配PFObjects、获取计数并按降序显示对象?,swift,parse-platform,count,match,Swift,Parse Platform,Count,Match,我知道很多。如果您可以帮助完成部分,请执行。我正在构建一个视频排名应用程序,并使用唯一的YouTube视频ID在解析中保存视频数据。我想匹配每个id的计数,并按降序显示每个id。基本上是前20名的应用程序。我的视频信息正在这样保存 let videoSave = PFObject(className: "UserVideos") videoSave.setObject(self.videoARY, forKey: "vid\(self.saveValueLBL.text!)")

我知道很多。如果您可以帮助完成部分,请执行。我正在构建一个视频排名应用程序,并使用唯一的YouTube视频ID在解析中保存视频数据。我想匹配每个id的计数,并按降序显示每个id。基本上是前20名的应用程序。我的视频信息正在这样保存

let videoSave = PFObject(className: "UserVideos")
        videoSave.setObject(self.videoARY, forKey: "vid\(self.saveValueLBL.text!)")
        videoSave["userObjectId"] = PFUser.currentUser()!.objectId
        videoSave["username"] = PFUser.currentUser()!.username
        videoSave["ytID"] = self.videoId
        videoSave.saveInBackgroundWithBlock { (success, error ) -> Void in
            if success == true
            {
                if videoSave["username"] == nil
                {
                    videoSave["username"] = PFUser.currentUser()!.username
                    videoSave.saveInBackground()
                }
            }
        } 
let query = PFQuery(className: "UserVideos")
query.whereKeyExists("vid1")
query.orderByDescending("ytID")
query.limit = 20
query.findObjectsInBackgroundWithBlock { (topVids , error ) -> Void in
    if !(error != nil)
    {
        print(topVids!)
    }
}
我要像这样把它们拿回来

let videoSave = PFObject(className: "UserVideos")
        videoSave.setObject(self.videoARY, forKey: "vid\(self.saveValueLBL.text!)")
        videoSave["userObjectId"] = PFUser.currentUser()!.objectId
        videoSave["username"] = PFUser.currentUser()!.username
        videoSave["ytID"] = self.videoId
        videoSave.saveInBackgroundWithBlock { (success, error ) -> Void in
            if success == true
            {
                if videoSave["username"] == nil
                {
                    videoSave["username"] = PFUser.currentUser()!.username
                    videoSave.saveInBackground()
                }
            }
        } 
let query = PFQuery(className: "UserVideos")
query.whereKeyExists("vid1")
query.orderByDescending("ytID")
query.limit = 20
query.findObjectsInBackgroundWithBlock { (topVids , error ) -> Void in
    if !(error != nil)
    {
        print(topVids!)
    }
}
*更新*

我在网上发现了一些东西,表明我做得对;我只需要将唯一的字符串匹配在一起,并使用“for循环”进行降序,例如,如果您对此有任何想法,请让我知道

请帮忙。谢谢