I hope this doesn't sound dumb but I'm trying to put:
let lowercasedQuery = query.lowercased()
let usersNew = users.filter({ $0.fullname.lowercased().contains(lowercasedQuery) || $0.username.contains(lowercasedQuery) })
into the DispatchQueue function but obviously, since they are constants declared in the function, the function is out of scope for the return line.
func filteredUsers(_ query: String) -> [User] {
let delay = 3.3
DispatchQueue.main.asyncAfter(deadline: .now() + delay)
{
}
let lowercasedQuery = query.lowercased()
let usersNew = users.filter({ $0.fullname.lowercased().contains(lowercasedQuery) || $0.username.contains(lowercasedQuery) })
return usersNew
}
Does anyone know how to solve this?
Thanks!