IOS 8: Исключение было завоевано от делегата nsfetchedresultscontroller, неверное обновление: неверное количество строк IOS

Программируем под IOS
Ответить
Anonymous
 IOS 8: Исключение было завоевано от делегата nsfetchedresultscontroller, неверное обновление: неверное количество строк

Сообщение Anonymous »

Полные журналы из моих nsfetchedresultscontrollerdelegate < /code> для iOS 8: < /p>

--- Запуск ---

-------- i

----- I

----- I

----- /> 2016-02-18 10: 42: 22.433 Posowner [9784: 66814] *** Ошибка утверждения в-[uitableview _endcellanimationswithContext:], /sourcecache/uikit_sim/uikit-3347.44.2/uitableview.m:1623 347.44.2/uitableview.m:1623. 10: 42: 22.440 Posowner [9784: 66814] Coredata: ошибка: серьезная ошибка приложения. Исключение было завоевано от делегата NSFetchEdresultsController во время вызова -контроллердидчангконта:. Неверное обновление: недопустимое количество строк в разделе 0. Количество строк, содержащихся в существующем разделе после обновления (1), должно быть равным количеству строк, содержащихся в этом разделе, до обновления (1), плюс или минус количество строк, вставленных или удаленных из этого раздела (1 вставлен, 0 удален) и плюс или мини - с userInfo (null)

--- Запуск ---

-------- d

-------- d

--------- d

--- Закончено --- < /p>
< /blockquote>
и для iOS 9 :- < /p> < /> < /> < /ploctore>
и для ios 9 :- < /p> < /> < /> < /> < /ploctore>
и для iOS 9 :- < /p> < /> < /> < /bloTe /> --- Запуск ---

-------- d

-------- d

-------- d

-------- i

--------

-------- i

----- /> И это мой nsfetchedresultscontrollerdelegate < /code>: < /p>

Код: Выделить всё

//MARK: - NSFetchedResultsControllerDelegate

func controllerWillChangeContent(controller: NSFetchedResultsController) {
print("---STARTED---")
tableView.beginUpdates()
}

func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) {

let indexSet = NSIndexSet(index: sectionIndex)

switch type {
case .Insert:
tableView.insertSections(indexSet, withRowAnimation: .Fade)
case .Delete:
tableView.deleteSections(indexSet, withRowAnimation: .Fade)
case .Update:
fallthrough
case .Move:
tableView.reloadSections(indexSet, withRowAnimation: .Fade)
}
}

func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {

switch type {
case .Insert:
print("--------I")
if let newIndexPath = newIndexPath {
tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Fade)
}
case .Delete:
print("--------D")
if let indexPath = indexPath {
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
}
case .Update:
print("--------U")
if let indexPath = indexPath, let cell = tableView.cellForRowAtIndexPath(indexPath) as? PBOTableViewCell {
updateCell(cell, indexPath: indexPath)
}
case .Move:
print("--------M")
if let indexPath = indexPath {
if let newIndexPath = newIndexPath {
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Fade)
}
}
}
}

func controllerDidChangeContent(controller: NSFetchedResultsController) {
print("---FINISHED---")
tableView.endUpdates()
}
и uitableviewdatasourceceedelegate :

Код: Выделить всё

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {

var numberOfSections = 0

if let sections = fetchedResultsController?.sections {
numberOfSections = sections.count
}

return numberOfSections
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

let workday = workDayObjectForSection(section)
return workday.worktimes.count
}

private func workDayObjectForSection(section: Int) -> PBOUserWorkDay {

let sections: NSArray? = fetchedResultsController.sections!
let sectionInfo = sections?.objectAtIndex(section) as? NSFetchedResultsSectionInfo
let workdays = sectionInfo?.objects as! [PBOUserWorkDay]

return workdays[0]
}
это происходит только на iOS 8. Есть обходные пути? Точно так же действие на iOS 9 работает как очарование. И каждый раз, когда это не работает на iOS 8.

Подробнее здесь: https://stackoverflow.com/questions/354 ... controller
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «IOS»