Let's use the following code example to elaborate on my question:
struct exampleObj {
var str: String?
var arr: [String]?
}
let filterArray = ["something1", "ins1", "something2"]
let obj1 = exampleObj(str: "obj1", arr: ["ins2", "ins3"])
let obj2 = exampleObj(str: "obj2", arr: ["ins1", "ins2"])
let obj3 = exampleObj(str: "obj3", arr: ["ins1", "ins4"])
let obj4 = exampleObj(str: "obj4", arr: ["ins3", "ins4"])
var arrayObj = [obj1, obj2, obj3, obj4]
let result = arrayObj.filter { filterArray.contains($0.arr...)} //??? I get lost here, dunno if right approach.
What I'm trying to do is to filter arrayObj by using another array filterArray, resulting on a result with only objects of type exampleObj containing ins1.
I hope I was clear. Any doubt about the question, I'm here.
struct ExampleObj { let str: String let arr: [String] }btw it is Swift naming convention to name your structures starting with an UppercaseLetter