Couchbase Lite
Objective-C API for iOS and Mac OS
CBLUITableSource.h
Go to the documentation of this file.
1 //
2 // CBLUITableSource.h
3 // CouchbaseLite
4 //
5 // Created by Jens Alfke on 8/2/11.
6 // Copyright 2011-2013 Couchbase, Inc. All rights reserved.
7 //
8 
9 #import "CBLBase.h"
10 #import <UIKit/UIKit.h>
12 
14 
20 @interface CBLUITableSource : NSObject <UITableViewDataSource, UIDataSourceModelAssociation>
21 
23 @property (nonatomic, retain) IBOutlet UITableView* tableView;
24 
26 @property (retain) CBLLiveQuery* query;
27 
29 -(void) reloadFromQuery;
30 
31 
32 #pragma mark Row Accessors:
33 
35 @property (nonatomic, readonly, nullable) CBLArrayOf(CBLQueryRow*)* rows;
36 
38 - (nullable CBLQueryRow*) rowAtIndex: (NSUInteger)index;
39 
41 - (nullable NSIndexPath*) indexPathForDocument: (CBLDocument*)document;
42 
44 - (nullable CBLQueryRow*) rowAtIndexPath: (NSIndexPath*)path;
45 
47 - (nullable CBLDocument*) documentAtIndexPath: (NSIndexPath*)path;
48 
49 
50 #pragma mark Displaying The Table:
51 
53 @property (nonatomic) UITableViewRowAnimation rowInsertAnimation;
55 @property (nonatomic) UITableViewRowAnimation rowDeleteAnimation;
57 @property (nonatomic) UITableViewRowAnimation rowReplaceAnimation;
58 
62 @property (copy, nullable) NSString* labelProperty;
63 
64 
65 #pragma mark Editing The Table:
66 
68 @property (nonatomic) BOOL deletionAllowed;
69 
71 - (BOOL) deleteDocumentsAtIndexes: (CBLArrayOf(NSIndexPath*)*)indexPaths
72  error: (NSError**)outError;
73 
75 - (BOOL) deleteDocuments: (CBLArrayOf(CBLDocument*)*)documents
76  error: (NSError**)outError;
77 
78 @end
79 
80 
82 @protocol CBLUITableDelegate <UITableViewDelegate>
83 @optional
84 
85 
87 - (void)couchTableSource:(CBLUITableSource*)source
88  willUseCell:(UITableViewCell*)cell
89  forRow:(CBLQueryRow*)row;
90 
93 - (nullable UITableViewCell *)couchTableSource:(CBLUITableSource*)source
94  cellForRowAtIndexPath:(NSIndexPath *)indexPath;
95 
97 - (void)couchTableSource:(CBLUITableSource*)source
98  willUpdateFromQuery:(CBLLiveQuery*)query;
99 
101 - (void)couchTableSource:(CBLUITableSource*)source
102  updateFromQuery:(CBLLiveQuery*)query
103  previousRows:(CBLArrayOf(CBLQueryRow*) *)previousRows;
104 
111 - (bool)couchTableSource:(CBLUITableSource*)source
112  deleteRow:(CBLQueryRow*)row;
113 
115 - (void)couchTableSource:(CBLUITableSource*)source
116  deleteFailed:(NSError*)error;
117 
118 @end
119 
120 
#define NS_ASSUME_NONNULL_BEGIN
Definition: CBLBase.h:20
UITableViewRowAnimation rowDeleteAnimation
Animation used when deleting rows; default is UITableViewRowAnimationAutomatic.
Definition: CBLUITableSource.h:55
A CBLQuery subclass that automatically refreshes the result rows every time the database changes...
Definition: CBLQuery.h:151
#define nullable
Definition: CBLBase.h:22
A CouchbaseLite document (as opposed to any specific revision of it.)
Definition: CBLDocument.h:16
UITableViewRowAnimation rowInsertAnimation
Animation used when inserting new rows; default is UITableViewRowAnimationAutomatic.
Definition: CBLUITableSource.h:53
#define NS_ASSUME_NONNULL_END
Definition: CBLBase.h:21
UITableViewRowAnimation rowReplaceAnimation
Animation used when replacing rows; default is UITableViewRowAnimationAutomatic.
Definition: CBLUITableSource.h:57
A result row from a CouchbaseLite view query.
Definition: CBLQuery.h:229
A UITableView data source driven by a CBLLiveQuery.
Definition: CBLUITableSource.h:20
CBLArrayOf(CBLQueryRow *) *rows
The current array of CBLQueryRows being used as the data source for the table.
CBLLiveQuery * query
The query whose rows will be displayed in the table.
Definition: CBLUITableSource.h:26
BOOL deletionAllowed
Is the user allowed to delete rows by UI gestures? (Defaults to NO.)
Definition: CBLUITableSource.h:68
void reloadFromQuery()
Rebuilds the table from the query&#39;s current .rows property.
IBOutlet UITableView * tableView
The table view to manage.
Definition: CBLUITableSource.h:23
NSString * labelProperty
If non-nil, specifies the property name of the query row&#39;s value that will be used for the table row&#39;...
Definition: CBLUITableSource.h:62