Skip to content

Instantly share code, notes, and snippets.

@CrystalKnightCodes
Created March 30, 2021 15:25
Show Gist options
  • Save CrystalKnightCodes/f604ebbb454f77aa246c58a59fe27192 to your computer and use it in GitHub Desktop.
Save CrystalKnightCodes/f604ebbb454f77aa246c58a59fe27192 to your computer and use it in GitHub Desktop.
TabView Tutorial Search Bar Method
struct SearchBarView: View {
//...
// MARK: - Methods
func findGroup() {
results = vacations.all { vacation -> Bool in
// First check to see if the text is in the vacation name
if vacation.name.localizedCaseInsensitiveContains(text) {
return true
// If it isn't in the vacation name, search through each place.
} else {
for place in vacation.places {
if place.name.localizedCaseInsensitiveContains(text) {
return true
}
}
}
return false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment