参见英文答案 >
how to check if a property value exists in array of objects in swift6个
我有一系列自定义对象.
我有一系列自定义对象.
我想检查数组是否包含一个对象,哪个属性等于string.
就像是
@H_404_6@if array.contains(object where object.name == name) { // do something } else { // don't do something }在Swift怎么办?
是,@H_404_6@if things.contains(where: { $0.someProperty == "nameToMatch" }) {
// found
} else {
// not
}