I am currently recording the discovery preference of a User (see image below) and would like to filter the list of Users being displayed in a CollectionView that meet the discovery preferences set by the User.
Every User in the array has a birthYear, gender and discoverable Bool.
This is my function which currently works for only the discoverable Bool and displays only User's which are set to true.
How do I chain the filter conditions that I need in order to only display those Users that meet the discovery preferences of a User above?
func discoverUsers(location: CLLocation) {
DataService.run.getUsersAtVenue(forVenueLocation: location, forUid: (Auth.auth().currentUser?.uid)!) { (users, success) in
if success {
self.users = users
self.filteredUsers = self.users.filter({ (user: User) -> Bool in
return user.discoverable == true
//-> Chain filter conditions to check for here: gender, age
})
self.collectionView.reloadData()
Utilities.run.dismissSVHUD(delay: 0.5)
}//end if
}//end closure
}//end func
}//end class
