【发布时间】:2019-01-31 05:04:00
【问题描述】:
我已经开始快速编程并尝试实现小型搜索功能。
我试图实现搜索框来搜索不同的飞机。对于在搜索框中输入的每个字符,应刷新结果。 我已经有一个获取飞机类型列表的 API。来自 API 的示例响应类型。
[
{
"type": "jet",
"seating": "single-seat",
"engine": "Two-engine",
"name": "Lockheed Martin F-35 Lightning II",
"nativeName": "Lockheed"
},
{
"type": "turbojet",
"seating": "double-seat",
"engine": "Two-engine",
"name": "Heinkel He 178",
"nativeName": "Heinkel"
}
]
我如何使用swift搜索飞机,结果显示在tableview中,搜索框中输入的每个字符,结果都应该刷新。
我使用下面的链接作为参考,但示例代码会有很大帮助。 https://medium.com/@nimjea/json-parsing-in-swift-2498099b78f
谢谢
【问题讨论】:
-
@dahiya_boy - 我不想在 tableview 中搜索,我想在得到 API 响应后在 tableview 中显示结果
-
@Manisha - 您需要将您的搜索字符发送到 API,然后解析 API 响应。
-
@dahiya_boy - 这是关于不在 tableview 中搜索