我正在使用Swift和Parse.com创建一个iOs应用程序。不幸的是,我在建立查询时遇到问题。
我想要的是:我和体育运动员一起上课(有进球和传球)。我想找回进球最多的球员和传球最多的球员。我的Parse类中有两列:目标和通过。
所以,对我来说,我会用
query_goals.limit = 1
query_goals.orderByDescending("goals")
query_passes.limit = 1
query_passes.orderByDescending("passes")
现在我需要对两个查询进行合并,但是在快速的iOS文档中没有找到任何关于此的内容...
请问有人有主意吗? :)
编辑:
我想在collectionView单元格中打印出最好的得分手和传球手:
override func queryForCollection() -> PFQuery {
let query = PFQuery(className: "liste_joueurs")
query.limit = 1
query.orderByDescending("goals")
let query_passes = PFQuery(className: "liste_joueurs")
query_passes.limit = 1
query.orderByDescending("passes")
let final_query = query + query_passes //Swift Concat to illustrate my purpose
return final_query
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath, object: PFObject!) -> PFCollectionViewCell? {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("statsCell", forIndexPath: indexPath) as! StatsViewCell
// First cell for best scorer
// Second cell for best passer
return cell
}
在 final_query 中,
最佳答案
let query = PFQuery(className : "SportsPlayers") // Im assuming your classname change it as needed
// for highest scorer
query.orderByDescending("goals")
query.limit = 1
// for highest passes
query.orderByDescending("passes")
query.limit = 1
关于ios - 解析-Swift:连接查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32036639/