Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- studentId = 1437404654;
- name = "Rancho";
- },
- {
- studentId = 1932617669;
- name = "Mastora";
- },
- {
- studentId = 1457367179;
- name = "Amanda";
- }
- {
- return myArr.count
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
- {
- let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! MyCell
- cell.idTextField.text = (dict.value(forKey: "studentId") as! String)
- cell.nameTextField.text = (dict.value(forKey: "name") as! String)
- }
- func searchBarTextDidEndEditing(_ searchBar: UISearchBar)
- }
- func searchBarCancelButtonClicked(_ searchBar: UISearchBar)
- }
- func searchBarSearchButtonClicked(_ searchBar: UISearchBar)
- }
- func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String)
- let predicate = NSPredicate(format: "%K CONTAINS[cd] %@ OR %K CONTAINS[cd] %@", "studentId", searchText, "name", searchText)
- let sorted = copyArr.filter({
- return predicate.evaluate(with: $0)
- })
- print(sorted)
- myArr.removeAllObjects()
- if sorted.count==0
- {
- myArr.addObjects(from: copyArr as! [Any])
- }
- else
- {
- myArr.addObjects(from: sorted)
- }
- resultTable.reloadData()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement