Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Serious application error" when CoreDataObservable used #332

Open
krasnodar95 opened this issue May 20, 2017 · 0 comments
Open

"Serious application error" when CoreDataObservable used #332

krasnodar95 opened this issue May 20, 2017 · 0 comments

Comments

@krasnodar95
Copy link

What

I got an error when using CoreDataObservable

[error] error: Serious application error.  An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:.  -[UICollectionViewUpdateItem _isCell]: unrecognized selector sent to instance 0x600000226a80 with userInfo (null)
CoreData: error: Serious application error.  An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:.  -[UICollectionViewUpdateItem _isCell]: unrecognized selector sent to instance 0x600000226a80 with userInfo (null)

Context

When the some data come in modifications section in method
update (deletions: [Int], insertions: [(index: Int, element: T)], modifications: [(index: Int, element: T)])

Proposal

I think that the problem in CoreDataObservable in this code

    // MARK: - NSFetchedResultsControllerDelegate
    
    public func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
        switch type {
        case .delete:
            self.batchChanges.append(.delete(indexPath![0], anObject as! T))
        case .insert:
            self.batchChanges.append(.insert(newIndexPath![0], anObject as! T))
        case .update:
            self.batchChanges.append(.update(indexPath![0], anObject as! T))
        default: break
        }
    }

You use the index 0, which is the index of the section and not of the cell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant