Aşağıdaki kod bir arama denetleyicisinin parçasıdır. Bu bir sorun olmadan çalışır ancak 8-10 aramalardan sonra, ben önemli bir hatayla (Konu 1: EXC_BAD_INSTRUCTION) karşılaştıkları aşağıdaki satırda:Önemli hata. İndeks yolundaki dizi dışı dizin - hızlı
let movie = filteredMovies[indexPath.item]
sorunlarla bu tür çözme yolunu tavsiye eder misiniz.
extension searchResults: UITableViewDataSource, UITableViewDelegate {
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("searchCell", forIndexPath: indexPath) as! searchResultCell
let movie = filteredMovies[indexPath.item]
cell.searchLabel.text = movie.title
let fileUrl = NSURL(string: movie.thumb)!
if let data = NSData(contentsOfURL: fileUrl)
{
cell.searchImage.contentMode = UIViewContentMode.ScaleAspectFit
cell.searchImage.image = UIImage(data: data)
// to make images rounded
cell.searchImage.backgroundColor = UIColor.clearColor()
cell.searchImage.layer.cornerRadius = 15.0
cell.searchImage.clipsToBounds = true
cell.backgroundColor = UIColor.clearColor()
}
return cell
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return filteredMovies.count
}
}
Yığın olduğu sırada yığın yığınını ve dizinin içeriğini göster – Wain
Tablo filtresini yeniden yüklemeden "filtrelenen öğeler" dizisini mutasyona uğratıyor musunuz? Filtrelenen şeyler için ne olduğunu bilmediğimizden sadece tahmin edebiliriz. – Eendje