我正在努力弄清楚为什么这段代码不能正常运作。我尝试使用搜索栏搜索某个项目,该搜索栏会过滤数据以突出显示与该词匹配或接近的任何内容。 (不确定我是否制作过滤器)到目前为止,当用户在搜索栏中列出商家的特定名称或参考时,我使用调用项目列表的代码。我究竟做错了什么?如何执行搜索以获取http请求中的正确数据?
func searchBarSearchButtonClicked(searchBar: UISearchBar!){
searchBar.resignFirstResponder()
searchItem = searchBar.text
performSearch(searchItem)
searchBar.delegate = self
}
func performSearch (text : String){
businessNames = [""]
businessID = [""]
var bodyData = "&key=(code)zqb&collection=www.(website).com_pcommdir&criteria=" + text.lowercaseStringWithLocale(NSLocale(localeIdentifier:"en")) + "&columnsAsAttributeList=&cartsiteid=1"
var url = NSURL(string: "https://www.(website).biz/codetemps/components/getAndroidDataVerity.cfm")
var request = NSMutableURLRequest(URL: url!)
request.HTTPMethod = "POST"
request.HTTPBody = bodyData.dataUsingEncoding(NSUTF8StringEncoding)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(),completionHandler:{ response, data, error in self.parseData(data) })
searchVar = 1
}