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

[Help] NSInternalInconsistencyException on Embedded/Nested Section #1044

Closed
bernaferrari opened this issue Dec 25, 2017 · 2 comments
Closed
Labels

Comments

@bernaferrari
Copy link

bernaferrari commented Dec 25, 2017

Hi! This is probably not related to IGListKit in the way "there is something wrong with the library", but in "I can't figure out this, and it is related to it, please help".

I thought it was a great idea to have a nested/embedded section controller, but I want to do operations inside them and between them. For example, in an attendance app example, I would like to tap the user in the top section (if you download the app and run, you will understand) and it goes to the second section; or if the user is in the second section, when tapping it goes to the first. Deleting or renaming is also allowed.

The problem is.. I have no idea how to do this with the current structure I have. EVERYTHING I try I get a "NSInternalInconsistencyException.. expected 3, but found 2" kind of thing. My structure is currently an array of ListDiffable's inside a ListDiffable. I'm not even doing a "move", only trying to remove before add anything and it is not working.

screenshot

I tried a collectionContext?.performBatch inside the SectionController, tried to remove items from an array, like self.presence?.items.removeAll(), tried to make a forEach() on data[Any], get the value I want, then perform the operation.. But I'm missing something (and probably not hard, but I don't know what). The self.adapter.performUpdates(..) is always there, so I'm not sure what it is..

BTW, if it is Ryan reading this, check my viewDidLayoutSubviews+viewWillTransition inside CollectionParent; it was the best solution for IGListKit rotation I've found to date. Might help your other apps.

NSInternalInconsistencyException.zip

@bernaferrari bernaferrari changed the title NSInternalInconsistencyException [Help] NSInternalInconsistencyException on Embedded/Nested Section Dec 25, 2017
@weyert
Copy link
Contributor

weyert commented Dec 25, 2017

Yes, if you are not using IGListCollectionLayout you could use something like below to invalidate the layout. I have had some issues myself with invalidating the layout after rotation only until now I have been unable to set breakpoints in IGListKit from inside my problematic app for some reason.

        let layout = collectionView.collectionViewLayout
        layout.invalidateLayout()
        coordinator.animate(alongsideTransition: { _ in
            self.adapter.performUpdates(animated: true, completion: nil)
            layout.invalidateLayout(with: layout.invalidationContext(forBoundsChange: CGRect(x: 0, y: 0, width: size.width, height: size.height)))
        })

I am curious the code of #976 might help with your query somehow?

@bernaferrari
Copy link
Author

bernaferrari commented Dec 25, 2017

I thought it was implemented yet, I'm going to use different sections for everything for now.. Thanks!
In 3.2.0, if I have any issue with it, I warn you. Thanks!

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

No branches or pull requests

3 participants