Swift 如果我打字太快,为什么我的搜索栏不工作?

Swift 如果我打字太快,为什么我的搜索栏不工作?,swift,swiftui,Swift,Swiftui,我链接了一个视频,如果我打字太快,你可以看到我的搜索栏不工作。这是我的代码: List{ ForEach(copyOfGeraete.filter({item in self.suchBegriffGeraete.isEmpty ? true : item.lowercased().contains(suchBegriffGeraete.lowercased())}), id: \.self){ item in

我链接了一个视频,如果我打字太快,你可以看到我的搜索栏不工作。这是我的代码:

List{
                        ForEach(copyOfGeraete.filter({item in self.suchBegriffGeraete.isEmpty ? true : item.lowercased().contains(suchBegriffGeraete.lowercased())}), id: \.self){ item in
                            NavigationLink(destination: Text("Destination")) {
                                Text(item)
                            }
                        }
                    }
当我的应用程序在“”下运行时,您可以下载我的屏幕视频

谢谢你的时间,如果有人知道它为什么会滞后,那就太好了


Boothosh

在模型类中使用Combine(
debounce
CombineTest
)进行过滤比直接在视图中进行过滤更可靠。除此之外,
localizedCaseInsensitiveContains
比反复调用
lowercased()
更有效。在类ViewModel中进行过滤。身体不应该做任何工作。它可能受到结构重新加载/刷新的影响