let textToSearch:String = "some text"
for nestedArray in myArray {
for item:User in nestedArray
if user.name.contains(textToSearch) || user.userName.contains(textToSearch)
print("found")
}
票数 3
EN
Stack Overflow用户
发布于
2016-09-20 22:06:46
let nestedArray: [[User]] = [[user1, user2], [user3], [user4, user5]]
let searchName = "foo"
let filteredArray = nestedArray.map({
return $0.filter({ $0.name == searchName })
}).filter({ $0.count > 0 })