文本字段自动完成与JSON响应 [英] TextField Autocompletion with JSON Response

查看:114
本文介绍了文本字段自动完成与JSON响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要什么:

我想在我的App.As我的数据是从Web服务来使用文本字段的自动完成,我想用JSON响应执行自动完成。

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" with the JSON Response.

我知道什么:

我知道,首先我必须从Web服务获取数据。然后,我需要分析它,并填写与解析的数据数组,然后我可以使用该数组来执行自动完成。

I know that first I have to fetch data from the web service. Then I need to parse it and fill the Array with that parsed data and then I can use that array to perform Auto Completion.

问题:

我不知道如何发送请求到得到JSON数据为每一个preFIX,在文本字段用户类型(意味着我想JSON数据类型时)。我知道如何执行JSON解析和文本字段的自动完成独立但对于文本字段自动完成与JSON响应不知道。我尝试了很多去寻找答案就这个,但我失败了。所以,请帮我...

I don't know how to send the requests to get JSON data for each "prefix" that user types in text field (means I want JSON Data during Typing). I know how to perform "JSON Parsing" and "Auto completion of text fields" independently but no idea regarding "TextField Autocompletion with JSON Response". I tried a lot to find the answer regarding this but i failed. So Please Help me...

我使用的是 doautocompletetextfield 执行文本域自动完成

对于这个问题更好的建议将AP preciated。

Better Suggestion for this problem will be appreciated.

任何解决方案?

推荐答案

您可以使用线性搜索就像在API的例子做,也可以在你的autoCompleteArray使用NS predicate快速搜索。

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

根据您的问题,你会先得到JSON数据,那么你需要从JSON保存相关数据插入到一些数组,然后你可以使用这个API来自动完成的文本字段。

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.

但我感到困惑的这句话:我不知道如何发送请求到得到JSON数据为每一个preFIX,在文本字段用户类型。
1)你想打字过程中获得Web服务的JSON数据?
2),或者你想打字过程中来从JSON字典数据?

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?

如果你想要去的选项(1),我认为这将是解决问题的烂路。
如果你想要去的选项(2),那么你需要解析JSON并提取您感兴趣的数据,并将其保存在数组中。然后做自动完成该数组的内容的基础上。

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.

这篇关于文本字段自动完成与JSON响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆