<view controller> 与协议 'UISearchBarDelegate' - Swift 的冗余一致性 4
Redundant conformance of <view controller> to protocol 'UISearchBarDelegate' - Swift 4
我有这个错误
Redundant conformance of 'TodoListViewController' to protocol '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()
}
}
class TodoListViewController 声明:
class TodoListViewController: UITableViewController, UISearchBarDelegate {
我已经对此进行了研究,没有其他问题对我的错误有效。
您在分机处添加委托 extension TodoListViewController: UISearchBarDelegate {
并在申报时
class TodoListViewController: UITableViewController, UISearchBarDelegate {
从声明中删除它
class TodoListViewController: UITableViewController {
}
我有这个错误
Redundant conformance of 'TodoListViewController' to protocol '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()
}
}
class TodoListViewController 声明:
class TodoListViewController: UITableViewController, UISearchBarDelegate {
我已经对此进行了研究,没有其他问题对我的错误有效。
您在分机处添加委托 extension TodoListViewController: UISearchBarDelegate {
并在申报时
class TodoListViewController: UITableViewController, UISearchBarDelegate {
从声明中删除它
class TodoListViewController: UITableViewController {
}