This is my observer code. It reloads the tableview, but still nothing comes
through.
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
[self.tableView reloadData];
}
I also have another tableview which I manually run a CBLQuery* to populate
(not a CBLLiveQuery), and it too has issues where on the initial load, it
doesn't think there are any rows. How do you think I should go about
adjusting my code to work with your new changes?
On Thursday, July 17, 2014 10:02:45 AM UTC-7, Jens Alfke wrote:
>
>
> On Jul 17, 2014, at 3:39 AM, Ragu Vijaykumar <[email protected]
> <javascript:>> wrote:
>
> self.labTagIdQuery = [[self.reference queryLabTagId] asLiveQuery];
> self.labTagIdQuery.limit = 30;
> [self.labTagIdQuery addObserver:self forKeyPath:@"rows" options:0
> context:NULL];
>
> - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
> return [self.labTagIdQuery.rows count];
> }
>
>
> There might be a race condition in your code that’s been triggered by some
> change in timing with the new code. CBLLiveQuery runs asynchronously, so
> its .rows property will initially be nil until the query has time to
> complete on the background thread. If your KV-observer method reloads the
> table view, you’re fine, but if not the view will get populated with
> whatever was in the query results at the time UIKit first loaded the table,
> which could be nil.
>
> If that’s not the case — i.e. if labTagIdQuery either never notifies you
> or its rows remains empty after the notification — let me know. I just
> wrote a quick test case verifying that live queries still work correctly
> with views that emit nil values (as yours does.)
>
> —Jens
>
> PS: I *did* find a regression involving live queries on views that emit
> ‘doc’ as the value, and pushed a fix a few minutes ago.
>
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/26ab02c4-d31a-402e-a8eb-0c276450bb7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.