Как получить вложенный массив при поиске во вложенном массиве.
struct Company {
let companyName:String
let employess:[Employees]
}
struct Employees {
let id:Int
let firstname:String
let lastname:String
}
let e11 = Employees(id: 1, firstname: "Hilton", lastname: "Joshua")
let e12 = Employees(id: 2, firstname: "Mikon", lastname: "Alex")
let e13 = Employees(id: 3, firstname: "Kiane", lastname: "Merton")
let company1 = Company(companyName: "X", employess: [e11,e12,e13])
let e21 = Employees(id: 1, firstname: "Minan", lastname: "Davis")
let e22 = Employees(id: 2, firstname: "Jeeth", lastname: "Haris")
let e23 = Employees(id: 3, firstname: "Joy", lastname: "Antony")
let company2 = Company(companyName: "Y", employess: [e21,e22,e23])
let e31 = Employees(id: 1, firstname: "Steffy", lastname: "Rex")
let e32 = Employees(id: 2, firstname: "Jerry", lastname: "Antony")
let e33 = Employees(id: 3, firstname: "Don", lastname: "Antony")
let company3 = Company(companyName: "Z", employess: [e31,e32,e33])
let companies = [company1,company2,company3]
если я ищу фамилию с помощью «Антоний», мне нужен результат как
[
Company(companyName: "Y", employess: [e23]), Company(companyName: "Z", employess: [e32,e33])
]