我正在尝试使用UISearchController但是我面临保留我无法解决的问题.MainTableview有两个部分.
第1节
过滤数据基于一些正则表达式
第2节
所有数据
我将UISearchController添加到我的tableview中,并将ResultsTableController作为resultsTableController附加.当用户搜索某些东西时,它工作,ResultsTableController出现,因为我将tableview委托设置为self,从我的MainTableViewController中的ResultsTableController调用didSelectRowAtIndexPath中选择项目.但是,如果用户从resultsTableController中选择了某些内容,则会出现分配问题.
以下是针对不同场景的
MainTableViewController.swift
var searchController: UISearchController!
// Secondary search results table view.
var resultsTableController: ResultsTableController!
var allCompanies = ["Data1","Data2","Data3"]
override func viewDidLoad() {
super.viewDidLoad()
resultsTableController = ResultsTableController()
// We want to be the delegate for our filtered table so didSelectRowAtIndexPath(_:) is called for both tables.
resultsTableController.tableView.delegate = self
searchController = UISearchController(searchResultsController: resultsTableController)
searchController.searchResultsUpdater = self
searchController.searchBar.sizeToFit()
tableView.tableHeaderView = searchController.searchBar
searchController.delegate = self
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.delegate = self
definesPresentationContext = true
} …Run Code Online (Sandbox Code Playgroud) 我有两个实体"CAR"和"COLOR".
在"COLOR"中,我有两个属性.
在"CAR"中,我有三个属性.
"COLOR"的id与"CAR"中的colourId相关.
请有人帮我写一个谓词,用于生成一种颜色的汽车阵列吗?