Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added new delegate method that allows hooking into the table view upd…

…ate process, reflecting changes in a more granular way that a blanket table reload.
  • Loading branch information...
commit c9d51e6672f65fffdb6a482be8edf6c321931bdd 1 parent 83b618c
Sven A. Schmidt authored
Showing with 17 additions and 1 deletion.
  1. +5 −0 UI/iOS/CouchUITableSource.h
  2. +12 −1 UI/iOS/CouchUITableSource.m
View
5 UI/iOS/CouchUITableSource.h
@@ -70,6 +70,11 @@
- (void)couchTableSource:(CouchUITableSource*)source
willUpdateFromQuery:(CouchLiveQuery*)query;
+/** Called after the query's results change to update the table view. If this method is not implemented by the delegate, reloadData is called on the table view.*/
+- (void)couchTableSource:(CouchUITableSource*)source
+ updateFromQuery:(CouchLiveQuery*)query
+ previousRows:(NSArray *)previousRows;
+
/** Called from -tableView:cellForRowAtIndexPath: just before it returns, giving the delegate a chance to customize the new cell. */
- (void)couchTableSource:(CouchUITableSource*)source
willUseCell:(UITableViewCell*)cell
View
13 UI/iOS/CouchUITableSource.m
@@ -104,10 +104,21 @@ - (void) setQuery:(CouchLiveQuery *)query {
-(void) reloadFromQuery {
CouchQueryEnumerator* rowEnum = _query.rows;
if (rowEnum) {
+ NSArray *oldRows = [_rows retain];
[_rows release];
_rows = [rowEnum.allObjects mutableCopy];
[self tellDelegate: @selector(couchTableSource:willUpdateFromQuery:) withObject: _query];
- [self.tableView reloadData];
+
+ id delegate = _tableView.delegate;
+ SEL selector = @selector(couchTableSource:updateFromQuery:previousRows:);
+ if ([delegate respondsToSelector: selector]) {
+ [delegate couchTableSource: self
+ updateFromQuery: _query
+ previousRows: oldRows];
+ } else {
+ [self.tableView reloadData];
+ }
+ [oldRows release];
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.