我有这个错误
“TodoListViewController”与“UISearchBarDelegate”协议的冗余一致性
错误出现在第1行的"UISearchBarDelegate“上。
extension TodoListViewController: UISearchBarDelegate {
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
let request : NSFetchRequest<Item> = Item.fetchRequest()
let predicate = NSPredicate(format: "title CONTAINS[cd] %@", searchBar.text!)
request.predicate = predicate
let sortDescriptor = NSSortDescriptor(key: "title", ascending: true)
request.sortDescriptors = [sortDescriptor]
do {
itemArray = try context.fetch(request)
} catch {
print("Error fetching data from context \(error)")
}
tableView.reloadData()
}
}TodoListViewController的类声明:
类TodoListViewController: UITableViewController,UISearchBarDelegate {
我已经研究过这个问题,没有其他问题是对我的错误有效的。
发布于 2018-06-09 11:42:59
在扩展extension TodoListViewController: UISearchBarDelegate {中添加委托
在声明中,class TodoListViewController: UITableViewController, UISearchBarDelegate {
将其从声明中删除
class TodoListViewController: UITableViewController {
}https://stackoverflow.com/questions/50773465
复制相似问题