no pudo obtener una celda de su fuente de datos con swift 3
Tengo el UITableViewController adjunto adjunto como searchResultsController:
import UIKit
import MapKit
class LocationSearchTable : UITableViewController {
var matchingItems:[MKMapItem] = []
var mapView: MKMapView? = nil
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
}
}
extension LocationSearchTable : UISearchResultsUpdating {
func updateSearchResults(for searchController: UISearchController){
guard let mapView = mapView,
let searchBarText = searchController.searchBar.text else { return }
let request = MKLocalSearchRequest()
request.naturalLanguageQuery = searchBarText
request.region = mapView.region
let search = MKLocalSearch(request: request)
search.start { response, _ in
guard let response = response else {
return
}
self.matchingItems = response.mapItems
self.tableView.reloadData()
}
}
}
extension LocationSearchTable {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
print(matchingItems.count)
return matchingItems.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")!
let selectedItem = matchingItems[indexPath.row].placemark
cell.textLabel?.text = selectedItem.name
cell.detailTextLabel?.text = ""
return cell
}
}
Aquí se estrelló una vezmatchingItems.count
no es igual a 0 por ejemplo:
0 0 10 2016-10-20 15: 43: 53.914 ios-App [9137: 977735]* Error de aserción en - [UITableView _configureCellForDisplay: forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3599.6/UITableView.m:8035 2016-10-20 15: 43: 53.927 ios -App [9137: 977735] * Finalización de la aplicación debido a la excepción no detectada 'NSInternalInconsistencyException', razón: 'UITableView (; layer =; contentOffset: {0, -64}; contentSize: {768, 440}>) no pudo obtener una celda de su dataSource
Cuando agrego puntos de depuración con cellForRowAtIndexPath que nunca se alcanzan, ¿la aplicación parece bloquearse antes de este punto?