FirebaseCollectionViewDataSource Class Reference
Inherits from | FirebaseDataSource : NSObject |
---|---|
Conforms to | UICollectionViewDataSource |
Declared in | FirebaseCollectionViewDataSource.h |
Overview
FirebaseCollectionViewDataSource provides an class that conforms to the UICollcetionViewDataSource protocol which allows UICollectionViews to implement FirebaseCollectionViewDataSource in order to provide a UICollectionView synchronized to a Firebase reference or query. In addition to handling all Firebase child events (added, changed, removed, moved), FirebaseCollectionViewDataSource handles UITableViewCell creation, either with the default UICollectionViewCell, prototype cells, custom UICollectionViewCell subclasses, or custom XIBs, and provides a simple [FirebaseCollectionViewDataSource populateCellWithBlock:] method which allows developers to populate the cells created for them with desired data from Firebase.
modelClass
The model class to coerce FDataSnapshots to (if desired). For instance, if the modelClass is set to [Message class] in Obj-C or Message.self in Swift, then objects of type Message will be returned instead of type FDataSnapshot.
@property (strong, nonatomic, __NON_NULL) Class modelClass
Discussion
The model class to coerce FDataSnapshots to (if desired). For instance, if the modelClass is set to [Message class] in Obj-C or Message.self in Swift, then objects of type Message will be returned instead of type FDataSnapshot.
Declared In
FirebaseCollectionViewDataSource.h
cellClass
The cell class to coerce UICollectionViewCells to (if desired). For instance, if the cellClass is set to [CustomCollectionViewCell class] in Obj-C or CustomCollectionViewCell in Swift, then objects of type CustomCollectionViewCell will be returned instead of type UICollectionViewCell.
@property (strong, nonatomic, __NON_NULL) Class cellClass
Discussion
The cell class to coerce UICollectionViewCells to (if desired). For instance, if the cellClass is set to [CustomCollectionViewCell class] in Obj-C or CustomCollectionViewCell in Swift, then objects of type CustomCollectionViewCell will be returned instead of type UICollectionViewCell.
Declared In
FirebaseCollectionViewDataSource.h
reuseIdentifier
The reuse identifier for cells in the UICollectionView.
@property (strong, nonatomic, __NON_NULL) NSString *reuseIdentifier
Discussion
The reuse identifier for cells in the UICollectionView.
Declared In
FirebaseCollectionViewDataSource.h
collectionView
The UICollectionView instance that operations (inserts, removals, moves, etc.) are performed against.
@property (strong, nonatomic, __NON_NULL) UICollectionView *collectionView
Discussion
The UICollectionView instance that operations (inserts, removals, moves, etc.) are performed against.
Declared In
FirebaseCollectionViewDataSource.h
hasPrototypeCell
Property to keep track of prototype cell use, to not register a class for the UICollectionView or do similar book keeping.
@property BOOL hasPrototypeCell
Discussion
Property to keep track of prototype cell use, to not register a class for the UICollectionView or do similar book keeping.
Declared In
FirebaseCollectionViewDataSource.h
populateCell
The callback to populate a subclass of UICollectionViewCell with an object provided by the datasource.
@property (strong, nonatomic, __NON_NULL) void ( ^ ) ( __KINDOF ( UICollectionViewCell ) __NON_NULL_PTR cell , __KINDOF ( NSObject ) __NON_NULL_PTR object ) populateCell
Discussion
The callback to populate a subclass of UICollectionViewCell with an object provided by the datasource.
Declared In
FirebaseCollectionViewDataSource.h
– initWithRef:cellReuseIdentifier:view:
Initialize an instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with FDataSnapshots.
- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView
Parameters
ref |
A Firebase reference to bind the datasource to |
---|---|
identifier |
A string to use as a CellReuseIdentifier |
collectionView |
An instance of a UICollectionView to bind to |
Return Value
An instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with FDataSnapshots
Discussion
Initialize an instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with FDataSnapshots.
Declared In
FirebaseCollectionViewDataSource.h
– initWithRef:prototypeReuseIdentifier:view:
Initialize an instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with FDataSnapshots. Note that this method is used when using prototype cells, where the cells don’t need to be registered in the class.
- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref prototypeReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView
Parameters
ref |
A Firebase reference to bind the datasource to |
---|---|
identifier |
A string to use as a CellReuseIdentifier |
collectionView |
An instance of a UICollectionView to bind to |
Return Value
An instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with FDataSnapshots
Discussion
Initialize an instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with FDataSnapshots. Note that this method is used when using prototype cells, where the cells don’t need to be registered in the class.
Declared In
FirebaseCollectionViewDataSource.h
– initWithRef:cellClass:cellReuseIdentifier:view:
Initialize an instance of FirebaseCollectionViewDataSource that populates a custom subclass of UICollectionViewCell with FDataSnapshots.
- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref cellClass:(__NULLABLE Class)cell cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView
Parameters
ref |
A Firebase reference to bind the datasource to |
---|---|
cell |
A subclass of UICollectionViewCell used to populate the UICollectionView, defaults to UICollectionViewCell if nil |
identifier |
A string to use as a CellReuseIdentifier |
collectionView |
An instance of a UICollectionView to bind to |
Return Value
An instance of FirebaseCollectionViewDataSource that populates a custom subclass of UICollectionViewCell with FDataSnapshots
Discussion
Initialize an instance of FirebaseCollectionViewDataSource that populates a custom subclass of UICollectionViewCell with FDataSnapshots.
Declared In
FirebaseCollectionViewDataSource.h
– initWithRef:nibNamed:cellReuseIdentifier:view:
Initialize an instance of FirebaseCollectionViewDataSource that populates a custom xib with FDataSnapshots.
- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref nibNamed:(__NON_NULL NSString *)nibName cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView
Parameters
ref |
A Firebase reference to bind the datasource to |
---|---|
nibName |
The name of a xib file to create the layout for a UICollectionViewCell |
identifier |
A string to use as a CellReuseIdentifier |
collectionView |
An instance of a UICollectionView to bind to |
Return Value
An instance of FirebaseCollectionViewDataSource that populates a custom xib with FDataSnapshots
Discussion
Initialize an instance of FirebaseCollectionViewDataSource that populates a custom xib with FDataSnapshots.
Declared In
FirebaseCollectionViewDataSource.h
– initWithRef:modelClass:cellReuseIdentifier:view:
Initialize an instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with a custom model class.
- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView
Parameters
ref |
A Firebase reference to bind the datasource to |
---|---|
model |
A custom class that FDataSnapshots are coerced to, defaults to FDataSnapshot if nil |
identifier |
A string to use as a CellReuseIdentifier |
collectionView |
An instance of a UICollectionView to bind to |
Return Value
An instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with a custom model class
Discussion
Initialize an instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with a custom model class.
Declared In
FirebaseCollectionViewDataSource.h
– initWithRef:modelClass:prototypeReuseIdentifier:view:
Initialize an instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with a custom model class. Note that this method is used when using prototype cells, where the cells don’t need to be registered in the class.
- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model prototypeReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView
Parameters
ref |
A Firebase reference to bind the datasource to |
---|---|
model |
A custom class that FDataSnapshots are coerced to, defaults to FDataSnapshot if nil |
identifier |
A string to use as a CellReuseIdentifier |
collectionView |
An instance of a UICollectionView to bind to |
Return Value
An instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with a custom model class
Discussion
Initialize an instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with a custom model class. Note that this method is used when using prototype cells, where the cells don’t need to be registered in the class.
Declared In
FirebaseCollectionViewDataSource.h
– initWithRef:modelClass:cellClass:cellReuseIdentifier:view:
Initialize an instance of FirebaseCollectionViewDataSource that populates a custom subclass of UICollectionViewCell with a custom model class.
- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model cellClass:(__NULLABLE Class)cell cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView
Parameters
ref |
A Firebase reference to bind the datasource to |
---|---|
model |
A custom class that FDataSnapshots are coerced to, defaults to FDataSnapshot if nil |
cell |
A subclass of UICollectionViewCell used to populate the UICollectionView, defaults to UICollectionViewCell if nil |
identifier |
A string to use as a CellReuseIdentifier |
collectionView |
An instance of a UICollectionView to bind to |
Return Value
An instance of FirebaseCollectionViewDataSource that populates a custom subclass of UICollectionViewCell with a custom model class
Discussion
Initialize an instance of FirebaseCollectionViewDataSource that populates a custom subclass of UICollectionViewCell with a custom model class.
Declared In
FirebaseCollectionViewDataSource.h
– initWithRef:modelClass:nibNamed:cellReuseIdentifier:view:
Initialize an instance of FirebaseCollectionViewDataSource that populates a custom xib with a custom model class.
- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model nibNamed:(__NON_NULL NSString *)nibName cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView
Parameters
ref |
A Firebase reference to bind the datasource to |
---|---|
model |
A custom class that FDataSnapshots are coerced to, defaults to FDataSnapshot if nil |
nibName |
The name of a xib file to create the layout for a UICollectionViewCell |
identifier |
A string to use as a CellReuseIdentifier |
collectionView |
An instance of a UICollectionView to bind to |
Return Value
An instance of FirebaseCollectionViewDataSource that populates a custom xib with a custom model class
Discussion
Initialize an instance of FirebaseCollectionViewDataSource that populates a custom xib with a custom model class.
Declared In
FirebaseCollectionViewDataSource.h
– populateCellWithBlock:
This method populates the fields of a UICollectionViewCell or subclass given an FDataSnapshot (or custom model object).
- (void)populateCellWithBlock:(__NON_NULL void ( ^ ) ( __KINDOF ( UICollectionViewCell ) __NON_NULL_PTR cell , __KINDOF ( NSObject ) __NON_NULL_PTR object ))callback
Parameters
callback |
A block which returns an initialized UICollectionViewCell (or subclass) and the corresponding object to populate the cell with. |
---|
Discussion
This method populates the fields of a UICollectionViewCell or subclass given an FDataSnapshot (or custom model object).
Declared In
FirebaseCollectionViewDataSource.h