我有一个模型如下:
class Expertise:NSObject{
var expertise:String = ""
var isSelevted:Bool = false
}
我想要所选专业知识的数组。
我试过:
Obj.filter{$0.isSelected == true}.first.expertise
但是上面那行没有用。
最佳答案
要获取数组中每个选定对象的专业知识值,请使用过滤器和映射:
objects.filter { $0.isSelected } .map { $0.expertise }
关于ios - 根据条件 Swift 获取模型对象的特定属性数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45902206/