Skip to content

Instantly share code, notes, and snippets.

@barisuyar
Last active November 7, 2022 12:57
Show Gist options
  • Save barisuyar/fda038a18921f85ac2a48d0ab3765981 to your computer and use it in GitHub Desktop.
Save barisuyar/fda038a18921f85ac2a48d0ab3765981 to your computer and use it in GitHub Desktop.
Filtered
@propertyWrapper
struct Filtered<T> where T: Filterable {
var filterString: String = ""
var wrappedValue: [T] = []
var filtered: [T] {
guard !filterString.isEmpty else { return wrappedValue }
return wrappedValue.filter({
$0.filterString.lowercased().range(of: filterString,
options: .caseInsensitive,
locale: Locale(identifier: "tr")) != nil
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment