ios - 如何在字符串列中使用 where 键数组?

标签 ios swift parse-platform

我有一个名称数组和一个字符串类型的列,我正在尝试获取信息。当我对 where 键中的每个值使用 for 循环时,我得到很多相同的信息,所以说有 5 个名字,我试图获取速率(一个整数)我会得到 100 个值而不是只需 5 个。

var name = ["Dog", "Cat", "Monkey"]
let query = PFQuery(className: "Animals")
    query.whereKey(not sure what to put since it is an array)
    query.findObjectsInBackgroundWithBlock { (objects: [PFObject]?, error: NSError?) in
        if(error == nil){
            for object in objects!{


                        if let rating = object["rate"] as? Int{
                            self.rater.append(rating)
                            print("rating \(self.rater)") //There are like 75-100 values
                        }
            }
        }else{
            print(error)
            }
        }

最佳答案

我不太了解Parse,但是有这个方法-whereKey:containedIn:它需要一个数组。那对你不起作用吗? (抱歉,我没有找到 Swift 文档)

文档说:

-whereKey:containedIn:

Add a constraint to the query that requires a particular key’s object to be contained in the provided array.

Declaration OBJECTIVE-C

- (nonnull instancetype)whereKey:(nonnull NSString *)key
                 containedIn:(nonnull NSArray *)array;

Parameters:

-key The key to be constrained.

-array The possible values for the key’s object.

关于ios - 如何在字符串列中使用 where 键数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36799985/

相关文章:

ios - 如何在 Swift 中访问 UIColor 的扩展?

ios - 解析试用期和数据存储限制

ios - 在具有循环关系的 saveAllInBackground 期间解析 iOS SDK 死锁

swift - 快速访问默认情况下的开关案例参数

Swift:在歌曲的某些部分引发 Action (avaudioplayer)

swift - 可以删除重复的代码,有更优雅的解决方案吗?

ios - 单元格中的个人资料图片未正确更新

ios - 正在保存的图像未出现

ios - 如何让 NSLocale.autoupdatingCurrentLocale() 只返回日期?

iOS MPMusicPlayerController 歌曲更改通知没有歌曲对象