Привет. Мне трудно исправить эту ошибку.
Завершение работы приложения из-за необработанного исключения «NSInvalidArgumentException», причина: «нет объекта с индексом 8 в разделе с индексом 21»
Эта ошибка возникает, когда я синхронизирую c всю песню из itunes в coredata и повторно ее получаю.
guard let artist: Artist = self.itemAtIndexPath(indexPath: indexPath) as? Artist else {
fatalError("artist == nil")
}
В функции itemAtIndexPath
func itemAtIndexPath(indexPath: IndexPath) -> NSFetchRequestResult? {
return indexPath.section < self.headingDataSource.count ? nil : self.fetchedItem(indexPath: indexPath)
}
при извлечении данных
func fetchedItem(indexPath: IndexPath) -> NSFetchRequestResult? {
let path: IndexPath = IndexPath(row: indexPath.row, section: indexPath.section - self.headingDataSource.count)
return self.fetchedResultsController()?.object(at: path)
}
я не знаю, почему возникает эта ошибка, и cra sh на фабрике c игнорируется при
return self.fetchedResultsController()?.object(at: path)
Пожалуйста, помогите мне решить эту проблему.