Here's a bit of code that you can throw in a playground. Given an array with a bunch of objects, it'll filter the array based on a property. Then it'll print the result.
class MyObj: CustomStringConvertible { var enabled = true var text = "" init(enabled: Bool, text: String) { self.enabled = enabled self.text = text } var description: String { return "MyObj=\(text)" } }
let collection = [ MyObj(enabled: true, text: "ja"), MyObj(enabled: true, text: "jawohl"), MyObj(enabled: false, text: "no"), MyObj(enabled: false, text: "nope"), MyObj(enabled: false, text: "non"), MyObj(enabled: true, text: "yep"), ]
print( collection.filter { $0.enabled } .map { $0.text } )