How to create autocomplete text field in Swift

前端 未结 2 677
挽巷
挽巷 2021-02-04 06:34

What I want to be able to create is an auto complete text field in iOS.

I have a form for selecting a client, wherein the user must select a client once using a text fie

2条回答
  •  礼貌的吻别
    2021-02-04 06:55

    Using Trie like structure will be a better option here. Based on entered string, trie will return top keywords (lets say 10) starting with the entered string. Implementing this trie on server side is better. When UI makes http call, calculations will be done on server side and server will send top results to UI. Then, UI will update TableView with new data.

    You can also do this with hashmap/dictionary but performance will be worse. Using trie/prefix tree approach will give you the best performance when you have thousands or millions of strings to check.

提交回复
热议问题