我想详细了解
.drive(resultsTableView.rx_itemsWithCellIdentifier("WikipediaSearchCell", cellType: WikipediaSearchCell.self)) { (_, viewModel, cell) in cell.viewModel = viewModel }
来自WikipediaSearchViewController.swift第47-64行.我试图提取参数来查看具体的类型签名,但重写为
let temp1 = searchBar.rx_text .asDriver() .throttle(0.3) .distinctUntilChanged() .flatMapLatest { query in API.getSearchResults(query) .retry(3) .retryOnBecomesReachable([], reachabilityService: ReachabilityService.sharedReachabilityService) .startWith([]) // clears results on new search term .asDriver(onErrorJustReturn: []) } .map { results in results.map(SearchResultViewModel.init) } let driveArg1 = resultsTableView.rx_itemsWithCellIdentifier("WikipediaSearchCell", cellType: WikipediaSearchCell.self) let driveArg2 = { (_, viewModel: SearchResultViewModel, cell: WikipediaSearchCell) in cell.viewModel = viewModel } temp1.drive(driveArg1, curriedArgument: driveArg2) .addDisposableTo(disposeBag)
给
不能使用类型'(String,cellType:UITableViewCell.Type)'的参数列表调用'rx_itemsWithCellIdentifier'
对于driveArg1和
没有更多上下文,表达式的类型是模糊的
对于driveArg2.
的签名drive
和rx_itemsWithCellIdentifier
有
public func drive(with: Self -> R1 -> R2, curriedArgument: R1) -> R2 {} public func rx_itemsWithCellIdentifier(cellIdentifier: String, cellType: Cell.Type = Cell.self)(source: O)(configureCell: (Int, S.Generator.Element, Cell) -> Void) -> Disposable {}
但在这一点上,Swift语法对我来说是难以理解的.任何人都可以解释签名和代码中发生的事情吗?