gpt4 book ai didi

ios - 如何使用对象列中的值作为 wherekey?

转载 作者:行者123 更新时间:2023-11-30 13:32:55 25 4
gpt4 key购买 nike

我正在尝试选取等于特定日期并匹配特定值的所有对象,但我不确定如何做到这一点。我需要获取日期包含 10 或更高的对象,因此在本例中它将拾取该对象,因为其中一个或两个的数字大于 10。

这是“数字”列,其类型为“对象”

{"Tue":[1, 0],
"Wed":[1]
}

ios代码:

 let query = PFQuery(className: "Animal")
//I don't know which wherekey to use
query.findObjectsInBackgroundWithBlock { (objects: [PFObject]?, error: NSError?) in
if(error == nil){
print(objects)

for object in objects!{
print(object)
}
}else{
print(error)
}
}

最佳答案

假设您的对象是 [String: [Int]] 类型:

let dict: [String: [Int]] = ["Tue": [1, 0], "Wed":[1]]
let filtered = dict.filter{ $0.1.filter{ $0 == 0 }.count > 0 }
print(filtered) // "Tue": [1, 0]

关于ios - 如何使用对象列中的值作为 wherekey?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36382073/

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