Last active
November 7, 2022 12:57
-
-
Save barisuyar/fda038a18921f85ac2a48d0ab3765981 to your computer and use it in GitHub Desktop.
Filtered
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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