Design a Live-Filtering Search Bar (Swift)
viaGlassdoor
Requirements: Design and implement a search bar in Swift such that, as the user types into it, the list below shows only the items whose names start with (or contain) the entered text, updating live as the user types.
Design/Approach: Bind the search text field to an observable state variable; on each text change, filter the backing data source (e.g. items.filter { $0.name.lowercased().hasPrefix(query.lowercased()) } or a contains check) and re-render the filtered list. Discussion points include debouncing rapid keystrokes for performance, case-insensitive matching, and handling the empty/no-match state.
asked …