20
20
21
21
@import UIKit;
22
22
23
- #import " FUIDataSource.h "
23
+ #import < FirebaseDatabaseUI/FUICollection.h >
24
24
25
25
NS_ASSUME_NONNULL_BEGIN
26
26
27
- @class FIRDatabaseReference;
28
-
29
27
/* *
30
28
* FUICollectionViewDataSource provides a class that conforms to the
31
29
* UICollectionViewDataSource protocol which allows UICollectionViews to
32
30
* adopt FUICollectionViewDataSource in order to provide a UICollectionView
33
31
* synchronized to a Firebase reference or query.
34
32
*/
35
- @interface FUICollectionViewDataSource : FUIDataSource <UICollectionViewDataSource>
33
+ @interface FUICollectionViewDataSource : NSObject <UICollectionViewDataSource>
36
34
37
35
/* *
38
36
* The UICollectionView instance that operations (inserts, removals, moves,
@@ -46,16 +44,19 @@ NS_ASSUME_NONNULL_BEGIN
46
44
* The callback to populate a subclass of UICollectionViewCell with an object
47
45
* provided by the datasource.
48
46
*/
49
- @property (strong , nonatomic , readonly ) UICollectionViewCell *(^populateCellAtIndexPath)
47
+ @property (strong , nonatomic , readonly ) UICollectionViewCell *(^populateCellAtIndexPath)
50
48
(UICollectionView *collectionView, NSIndexPath *indexPath, FIRDataSnapshot *object);
51
49
50
+ /* *
51
+ * The number of items in the data source.
52
+ */
53
+ @property (nonatomic , readonly ) NSUInteger count;
54
+
52
55
/* *
53
56
* Initialize an instance of FUICollectionViewDataSource that populates
54
57
* UICollectionViewCells with FIRDataSnapshots.
55
58
* @param collection A FUICollection that the data source uses to pull snapshots
56
59
* from Firebase Database.
57
- * @param view An instance of a UICollectionView to bind to. This view
58
- * is not retained by its data source.
59
60
* @param populateCell A closure used by the data source to create the cells that
60
61
* are displayed in the collection view. This closure is retained by the data
61
62
* source, so if you capture self in the closure and also claim ownership of the
@@ -64,7 +65,6 @@ NS_ASSUME_NONNULL_BEGIN
64
65
* UICollectionViewCells with FIRDataSnapshots.
65
66
*/
66
67
- (instancetype )initWithCollection : (id <FUICollection>)collection
67
- view : (UICollectionView *)view
68
68
populateCell : (UICollectionViewCell *(^)(UICollectionView *collectionView,
69
69
NSIndexPath *indexPath,
70
70
FIRDataSnapshot *object))populateCell NS_DESIGNATED_INITIALIZER;
@@ -73,8 +73,6 @@ NS_ASSUME_NONNULL_BEGIN
73
73
* Initialize an unsorted instance of FUICollectionViewDataSource that populates
74
74
* UICollectionViewCells with FIRDataSnapshots.
75
75
* @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.
78
76
* @param populateCell A closure used by the data source to create the cells that
79
77
* are displayed in the collection view. This closure is retained by the data
80
78
* source, so if you capture self in the closure and also claim ownership of the
@@ -83,12 +81,23 @@ NS_ASSUME_NONNULL_BEGIN
83
81
* UICollectionViewCells with FIRDataSnapshots.
84
82
*/
85
83
- (instancetype )initWithQuery : (FIRDatabaseQuery *)query
86
- view : (UICollectionView *)collectionView
87
84
populateCell : (UICollectionViewCell *(^)(UICollectionView *collectionView,
88
85
NSIndexPath *indexPath,
89
86
FIRDataSnapshot *object))populateCell ;
90
87
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 ;
92
101
93
102
@end
94
103
0 commit comments