-
Notifications
You must be signed in to change notification settings - Fork 114
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
Binding an ObservableCollection to a Collection View #20
Comments
Hi @ramirez, hmm, that sounds bad. Could you post the code related to ObservableCollection and a Collection View and how are using it? |
Hi, my problem seems to be that I keep changing the contents of the collection I'm using, based on an observed value. I have a ViewModel that has:
and I observe a variable that triggers a repopulation of the collection (One suspect that I have is that I put that in Init. Maybe I should do that binding later):
In my view I bind the observable collection to my collectionView:
That's mostly it. The rest of the code is just layout. The malloc error is reported in a line of in particular the init method:
when calling: `uSelf.collectionView.performBatchUpdates`` Could it be that I'm modifying the collection before doing the binding to the collectionView a problem? LEo |
Hmm, we might have a bug in the binding... What happens if you replace self.localPosts.removeAll()
self.localPosts.insertContentsOf(value, at: 0) with self.localPosts.replace(value) That basically does the same thing, just in one line. I'll try to reproduce modifying the collection before doing the binding - but that should also work. |
I tried but I get the same. The only way I found to make it work is by doing the binding before ever touching the collection. |
Hi @ramirez, I've traced the issue to table/collection view binding. Just released ReactiveUIKit 1.0.9 with the issue fixed. Please confirm if it works. Thanks! |
Works. Thx! LEo |
I use ReactiveUIKit 1.0.9 unfortunately it crashes after I update the data
And I use the same function |
Looks like I have to spend some more time on this :) @retsohuang is it collection or table view? |
That issue appears both CollectionView and TableView. |
Hi @retsohuang, could you provide some more context around the issues? I'm having hard time reproducing this... |
I'll try to create demo project that reproduce this issue. |
This looks like its related to ReactiveKit/ReactiveUIKit#3. Try removing the |
I'm 99% sure that this is fixed by ReactiveKit/ReactiveUIKit#5. I'd love to get this pulled in ASAP @srdanrasic |
Hi,
is there any more extensive example of binding an observableCollection of a collectionView? I'm porting an app I had in SwiftBond to ReactiveKit. I'm trying using the way explained here in the documentation and also using some inspiration from the SwiftBond demo app but I can't seem to be able to figure it out. I either get:
malloc: *** error for object 0x7fa13512a718: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
from the ReactiveUIKit extension, or
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (29) must be equal to the number of items contained in that section before the update (29), plus or minus the number of items inserted or deleted from that section (29 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).'
on the same code. Any ideas or hints?
Thx!
LEo
The text was updated successfully, but these errors were encountered: