I try to implement search to my tableview, I got the following error. How I am going to implement for JSON data?
var articleList: [JSON]? = []
var searchResults: [JSON]? = []
And my updateSearchResultsForSearchController function :
func updateSearchResultsForSearchController(searchController: UISearchController) {
self.searchResults?.removeAll(keepCapacity: false)
let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %@", searchController.searchBar.text)
let array = (articleList as NSArray).filteredArrayUsingPredicate(searchPredicate)
searchResults = array as! [String]
self.tableView.reloadData()
}
ERROR : '[JSON]?' is not convertible to 'NSArray'
Thanks...
Make (instead of cast) a new NSArray from your Swift array:
Then use it: