|
28 | 28 |
|
29 | 29 | #import <UIKit/UIKit.h>
|
30 | 30 |
|
31 |
| -#import "FirebaseDataSource.h" |
| 31 | +#import <FirebaseUI/FirebaseDataSource.h> |
32 | 32 |
|
33 | 33 | @interface FirebaseTableViewDataSource : FirebaseDataSource <UITableViewDataSource>
|
34 | 34 |
|
| 35 | +/** |
| 36 | + * The model class to coerce FDataSnapshots to (if desired). For instance, if the modelClass is set to [Message class], then objects of type Message will be returned instead of type FDataSnapshot. |
| 37 | + */ |
| 38 | +@property (strong, nonatomic) Class modelClass; |
| 39 | + |
| 40 | +/** |
| 41 | + * The reuse identifier for cells in the UITableView. |
| 42 | + */ |
| 43 | +@property (strong, nonatomic) NSString *reuseIdentifier; |
| 44 | + |
| 45 | +/** |
| 46 | + * The UITableView instance that operations (inserts, removals, moves, etc.) are performed against. |
| 47 | + */ |
35 | 48 | @property (strong, nonatomic) UITableView *tableView;
|
36 |
| -@property (strong, nonatomic) void(^populateCell)(id cell, id snap); |
37 | 49 |
|
| 50 | +/** |
| 51 | + * The callback to populate a subclass of UITableViewCell with an object provided by the datasource. |
| 52 | + */ |
| 53 | +@property (strong, nonatomic) void(^populateCell)(id cell, id object); |
| 54 | + |
| 55 | +/** |
| 56 | + * Initialize an instance of FirebaseTableViewDataSource that populates UITableViewCells with FDataSnapshots. |
| 57 | + * @param ref A Firebase reference to bind the datasource to |
| 58 | + * @param identifier A string to use as a CellReuseIdentifier |
| 59 | + * @param tableView An instance of a UITableView to bind to |
| 60 | + * @return An instance of FirebaseTableViewDataSource that populates UITableViewCells with FDataSnapshots |
| 61 | + */ |
38 | 62 | - (instancetype)initWithRef:(Firebase *)ref reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView;
|
| 63 | + |
| 64 | +/** |
| 65 | + * Initialize an instance of FirebaseTableViewDataSource that populates a custom subclass of UITableViewCell with FDataSnapshots. |
| 66 | + * @param ref A Firebase reference to bind the datasource to |
| 67 | + * @param cell A subclass of UITableViewCell that will |
| 68 | + * @param identifier A string to use as a CellReuseIdentifier |
| 69 | + * @param tableView An instance of a UITableView to bind to |
| 70 | + * @return An instance of FirebaseTableViewDataSource that populates a custom subclass of UITableViewCell with FDataSnapshots |
| 71 | + */ |
39 | 72 | - (instancetype)initWithRef:(Firebase *)ref cellClass:(Class)cell reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView;
|
40 |
| -- (instancetype)initWithRef:(Firebase *)ref nibNamed:(NSString *)name reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; |
| 73 | + |
| 74 | +/** |
| 75 | + * Initialize an instance of FirebaseTableViewDataSource that populates a custom xib with FDataSnapshots. |
| 76 | + * @param ref A Firebase reference to bind the datasource to |
| 77 | + * @param nibName The name of a xib file to create the layout for a UITableViewCell |
| 78 | + * @param identifier A string to use as a CellReuseIdentifier |
| 79 | + * @param tableView An instance of a UITableView to bind to |
| 80 | + * @return An instance of FirebaseTableViewDataSource that populates a custom xib with FDataSnapshots |
| 81 | + */ |
| 82 | +- (instancetype)initWithRef:(Firebase *)ref nibNamed:(NSString *)nibName reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; |
| 83 | + |
| 84 | +/** |
| 85 | + * Initialize an instance of FirebaseTableViewDataSource that populates UITableViewCells with a custom model class. |
| 86 | + * @param ref A Firebase reference to bind the datasource to |
| 87 | + * @param model A custom class that FDataSnapshots are coerced to |
| 88 | + * @param identifier A string to use as a CellReuseIdentifier |
| 89 | + * @param tableView An instance of a UITableView to bind to |
| 90 | + * @return An instance of FirebaseTableViewDataSource that populates UITableViewCells with a custom model class |
| 91 | + */ |
41 | 92 | - (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView;
|
| 93 | + |
| 94 | +/** |
| 95 | + * Initialize an instance of FirebaseTableViewDataSource that populates a custom subclass of UITableViewCell with a custom model class. |
| 96 | + * @param ref A Firebase reference to bind the datasource to |
| 97 | + * @param model A custom class that FDataSnapshots are coerced to |
| 98 | + * @param cell A subclass of UITableViewCell that will |
| 99 | + * @param identifier A string to use as a CellReuseIdentifier |
| 100 | + * @param tableView An instance of a UITableView to bind to |
| 101 | + * @return An instance of FirebaseTableViewDataSource that populates a custom subclass of UITableViewCell with a custom model class |
| 102 | + */ |
42 | 103 | - (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model cellClass:(Class)cell reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView;
|
43 |
| -- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model nibNamed:(NSString *)name reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; |
44 | 104 |
|
45 |
| -- (void)populateCellWithBlock:(void(^)(id cell, id snap))callback; |
| 105 | +/** |
| 106 | + * Initialize an instance of FirebaseTableViewDataSource that populates a custom xib with a custom model class. |
| 107 | + * @param ref A Firebase reference to bind the datasource to |
| 108 | + * @param model A custom class that FDataSnapshots are coerced to |
| 109 | + * @param nibName The name of a xib file to create the layout for a UITableViewCell |
| 110 | + * @param identifier A string to use as a CellReuseIdentifier |
| 111 | + * @param tableView An instance of a UITableView to bind to |
| 112 | + * @return An instance of FirebaseTableViewDataSource that populates a custom xib with a custom model class |
| 113 | + */ |
| 114 | +- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model nibNamed:(NSString *)nibName reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; |
| 115 | + |
| 116 | +/** |
| 117 | + * This method populates the fields of a UITableViewCell or subclass given a model object (or FDataSnapshot). |
| 118 | + * @param callback A block which returns an initialized UITableViewCell (or subclass) and the corresponding object to populate the cell with. |
| 119 | + */ |
| 120 | +- (void)populateCellWithBlock:(void(^)(id cell, id object))callback; |
46 | 121 |
|
47 | 122 | @end
|
48 | 123 |
|
0 commit comments