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

NSInternalInconsistencyException on Collection View Updating #5

Closed

Conversation

AnthonyMDev
Copy link

This fixes #3 and DeclarativeHub/ReactiveKit#11.

The .gitmodule file needed to be removed in order for me to clone the repository, as I don't have access to the submodules. @srdanrasic, I don't know of a better way to handle that...

@srdanrasic
Copy link
Contributor

Thanks @AnthonyMDev! Now I'm very puzzled why this fixed it :)

@srdanrasic
Copy link
Contributor

Does the issue occur only when moving/reordering items? I'm having trouble reproducing this.

@AnthonyMDev
Copy link
Author

This is caused by a bug in UICollectionView. There isn't a really great explanation of the cause out there. This is the best information I can show you.
http://stackoverflow.com/questions/18796891/uicollectionview-reloaddata-not-functioning-properly-in-ios-7

@srdanrasic
Copy link
Contributor

Playing further with this... It seams that in the implementation of collectionView:moveItemAtIndexPath we should not trigger any events because collection view already laid out itself to the new state and we should just update our data. ObservableCollection currently does not support modifying the collection without triggering the events...

I'm thinking of adding a way to do silent updates of the observable collection, like:

array.silentUpdate { proxy in
  proxy.moveItemAtIndex(0, toIndex: 3)
}

@@ -72,19 +72,21 @@ public class RKCollectionViewDataSource<C: ObservableCollectionType where C.Coll

collectionView.dataSource = self
collectionView.reloadData()

observableCollection.skip(1).observe(on: ImmediateOnMainExecutionContext) { [weak self] event in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just change ImmediateOnMainExecutionContext to MainExecutionContext and it will do dispatch_async(dispatch_get_main_queue()... :)

@AnthonyMDev
Copy link
Author

@srdanrasic I've updated the PR to use 'MainExecutionContext'.
Adding a 'silentUpdate' method is not a bad idea!

@srdanrasic
Copy link
Contributor

Added this manually so I'll close this. Available in v1.0.10.

Can you check if it still crashes? I guess you should now do the collectionView:moveItemAtIndexPath updates within the silentUpdate...

@srdanrasic srdanrasic closed this Dec 30, 2015
@AnthonyMDev
Copy link
Author

@srdanrasic This is causing me issues again. When we had updated to use MainExecutionContext, everything seemed to be working. Once you made the updates to use Queue.main.context, it broke again...

@AnthonyMDev
Copy link
Author

Never mind, I had another issue that was causing this. This code looks good. Thanks @srdanrasic !

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

Successfully merging this pull request may close these issues.

Binding to UICollectionView not initially configuring collection view
2 participants