I have an array of a Category class that has a name and parentName. I have a search bar to allow users search for categories by the category name or parentName. My full array has about 600 items. On typing the first letter it takes about 2-3 seconds and freezes all other input on the keyboard. After the first letter everything is fast.
Here is how I am filtering
return self.userData.categories.filter({$0.name.lowercased().hasPrefix(searchText.lowercased()) || ($0.parentName != nil && $0.parentName!.lowercased().hasPrefix(searchText.lowercased()))})
One piece I think it may be is SwiftUI rendering all of the rows, however the initial render is fast.
This is how I render the categories.
List(categories) { category in
CategoryPickerRowView(category: category, isSelected: category.id == self.transaction.categoryId)
.onTapGesture { self.transaction.categoryId = category.id }
}
Update: I noticed when the first letter is typed or deleted (when it is slow) I get this message in the logs
[Snapshotting] Snapshotting a view (0x7fb6bd4b8080, _UIReplicantView) that has not been rendered at least once requires afterScreenUpdates:YES.