2020
2121@import UIKit;
2222
23- #import " FUIDataSource.h "
23+ #import < FirebaseDatabaseUI/FUICollection.h >
2424
2525NS_ASSUME_NONNULL_BEGIN
2626
27- @class FIRDatabaseReference;
28-
2927/* *
3028 * FUICollectionViewDataSource provides a class that conforms to the
3129 * UICollectionViewDataSource protocol which allows UICollectionViews to
3230 * adopt FUICollectionViewDataSource in order to provide a UICollectionView
3331 * synchronized to a Firebase reference or query.
3432 */
35- @interface FUICollectionViewDataSource : FUIDataSource <UICollectionViewDataSource>
33+ @interface FUICollectionViewDataSource : NSObject <UICollectionViewDataSource>
3634
3735/* *
3836 * The UICollectionView instance that operations (inserts, removals, moves,
@@ -46,16 +44,19 @@ NS_ASSUME_NONNULL_BEGIN
4644 * The callback to populate a subclass of UICollectionViewCell with an object
4745 * provided by the datasource.
4846 */
49- @property (strong , nonatomic , readonly ) UICollectionViewCell *(^populateCellAtIndexPath)
47+ @property (strong , nonatomic , readonly ) UICollectionViewCell *(^populateCellAtIndexPath)
5048 (UICollectionView *collectionView, NSIndexPath *indexPath, FIRDataSnapshot *object);
5149
50+ /* *
51+ * The number of items in the data source.
52+ */
53+ @property (nonatomic , readonly ) NSUInteger count;
54+
5255/* *
5356 * Initialize an instance of FUICollectionViewDataSource that populates
5457 * UICollectionViewCells with FIRDataSnapshots.
5558 * @param collection A FUICollection that the data source uses to pull snapshots
5659 * from Firebase Database.
57- * @param view An instance of a UICollectionView to bind to. This view
58- * is not retained by its data source.
5960 * @param populateCell A closure used by the data source to create the cells that
6061 * are displayed in the collection view. This closure is retained by the data
6162 * source, so if you capture self in the closure and also claim ownership of the
@@ -64,7 +65,6 @@ NS_ASSUME_NONNULL_BEGIN
6465 * UICollectionViewCells with FIRDataSnapshots.
6566 */
6667- (instancetype )initWithCollection : (id <FUICollection>)collection
67- view : (UICollectionView *)view
6868 populateCell : (UICollectionViewCell *(^)(UICollectionView *collectionView,
6969 NSIndexPath *indexPath,
7070 FIRDataSnapshot *object))populateCell NS_DESIGNATED_INITIALIZER;
@@ -73,8 +73,6 @@ NS_ASSUME_NONNULL_BEGIN
7373 * Initialize an unsorted instance of FUICollectionViewDataSource that populates
7474 * UICollectionViewCells with FIRDataSnapshots.
7575 * @param query A Firebase query to bind the data source to.
76- * @param collectionView An instance of a UICollectionView to bind to. This view
77- * is not retained by its data source.
7876 * @param populateCell A closure used by the data source to create the cells that
7977 * are displayed in the collection view. This closure is retained by the data
8078 * source, so if you capture self in the closure and also claim ownership of the
@@ -83,12 +81,23 @@ NS_ASSUME_NONNULL_BEGIN
8381 * UICollectionViewCells with FIRDataSnapshots.
8482 */
8583- (instancetype )initWithQuery : (FIRDatabaseQuery *)query
86- view : (UICollectionView *)collectionView
8784 populateCell : (UICollectionViewCell *(^)(UICollectionView *collectionView,
8885 NSIndexPath *indexPath,
8986 FIRDataSnapshot *object))populateCell ;
9087
91- - (instancetype )initWithCollection : (id <FUICollection>)collection NS_UNAVAILABLE;
88+ - (instancetype )init NS_UNAVAILABLE;
89+
90+ /* *
91+ * Attaches the data source to a collection view and begins sending updates immediately.
92+ * @param view An instance of UICollectionView that the data source should push
93+ * updates to.
94+ */
95+ - (void )bindToView : (UICollectionView *)view ;
96+
97+ /* *
98+ * Detaches the data source from a view and stops sending any updates.
99+ */
100+ - (void )unbind ;
92101
93102@end
94103
0 commit comments