TextField Autocompletion with JSON Response

前端 未结 1 1783
感情败类
感情败类 2021-01-24 12:25

What I want :

I want to use Auto Completion of Text field in my App.As my data is coming from the web service, I want to perform the \"Auto Completion\"

1条回答
  •  囚心锁ツ
    2021-01-24 12:50

    You can use linear searching just like done in the api example or can use NSPredicate for fast searching in your autoCompleteArray.

    According to your problem, you will get json data first, then you need to save relevant data from json into some array and then you can use this api to autocomplete the text in text field.

    But i am confused about your this statement: "I don't know how to send the requests to get JSON data for each "prefix" that user types in text field." 1) Do you want to get json data from web service during typing? 2) Or you want to fetch data from json dictionary during typing?

    If you want to go with option (1), i think it would be bad way to solve the problem. And if you want to go with option (2) then you need to parse json and extract data of your interest and save it in an array. And then do autocomplete on the basis of the contents of that array.

    0 讨论(0)
提交回复
热议问题