You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: FirebaseUI/API/FirebaseArray.h
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,7 @@
32
32
33
33
@class FQuery;
34
34
@class Firebase;
35
+
@class FDataSnapshot;
35
36
36
37
/**
37
38
* FirebaseArray provides an array structure that is synchronized with a Firebase reference or query. It is useful for building custom data structures or sources, and provides the base for FirebaseDataSource.
@@ -10,24 +10,21 @@ We recommend using [CocoaPods](http://cocoapods.org/?q=firebaseui-ios), add
10
10
the following to your `Podfile`:
11
11
12
12
```
13
-
pod 'FirebaseUI', '>= 0.1.0'
13
+
pod 'FirebaseUI', '~> 0.2'
14
+
```
15
+
16
+
If you're including FirebaseUI in a Swift project, make sure you also have:
17
+
18
+
```
19
+
platform :ios, '8.0'
20
+
use_frameworks!
14
21
```
15
22
16
23
Otherwise, you can download the latest version of the [FirebaseUI.framework from the releases
17
24
page](https://github.com/firebase/FirebaseUI-iOS/releases) or include the FirebaseUI
18
25
Xcode project from this repo in your project. You also need to [add the Firebase
19
26
framework](https://www.firebase.com/docs/ios-quickstart.html?utm_source=firebaseui-ios) to your project.
20
27
21
-
### Using FirebaseUI with Swift
22
-
23
-
In order to use FirebaseUI in a Swift project, you'll also need to setup a bridging
24
-
header, in addition to adding the Firebase and FirebaseUI frameworks
25
-
to your project. To do that, [follow these instructions](https://www.firebase.com/docs/ios/guide/setup.html#section-swift), and then add the following line to your bridging header:
26
-
27
-
````objective-c
28
-
#import<FirebaseUI/FirebaseUI.h>
29
-
````
30
-
31
28
## Getting Started with Firebase
32
29
33
30
FirebaseUI requires Firebase in order to store location data. You can [sign up here for a free
@@ -41,16 +38,16 @@ This is a quickstart on how to use FirebaseUI's core features to speed up iOS de
41
38
42
39
FirebaseTableViewDataSource implements the UITableViewDataSource protocol to automatically use Firebase as a DataSource for your UITableView.
self.dataSource.populateCellWithBlock { (cell: UITableViewCell, obj: NSObject) -> Void in
73
+
let snap = obj as! FDataSnapshot
74
+
75
+
// Populate cell as you see fit, like as below
76
+
cell.textLabel?.text = snap.key as String
77
+
}
78
+
79
+
self.tableView.dataSource = self.dataSource
67
80
68
-
You can use FirebaseTableViewDataSource in several ways to create custom UITableViews. For more information on how to create custom UITableViews, check out the following tutorial on [TutsPlus](http://code.tutsplus.com/tutorials/ios-sdk-crafting-custom-uitableview-cells--mobile-15702).
81
+
```
69
82
70
-
### Using the Default UITableViewCell Implementation
83
+
### FirebaseCollectionViewDataSource
71
84
72
-
You can use the default UITableViewCell implementation to get up and running quickly. This allows for the `cell.textLabel` and the `cell.detailTextLabel` to be used directly out of the box.
85
+
FirebaseCollectionViewDataSource implements the UICollectionViewDataSource protocol to automatically use Firebase as a DataSource for your UICollectionView.
self.dataSource.populateCellWithBlock { (cell: UICollectionViewCell, obj: NSObject) -> Void in
119
+
let snap = obj as! FDataSnapshot
120
+
121
+
// Populate cell as you see fit, like as below
122
+
cell.backgroundColor = UIColor.blueColor()
123
+
}
124
+
125
+
self.collectionView.dataSource = self.dataSource
126
+
127
+
```
86
128
87
-
Create a storyboard that has either a UITableViewController or a UIViewController with a UITableView. Drag a prototype cell onto the UITableView and give it a custom ReuseIdentifier. Drag and other properties onto the cell and associate them with properties of a UITableViewCell subclass.
129
+
## Customizing your UITableView or UICollectionView
88
130
131
+
You can use `FirebaseTableViewDataSource` or `FirebaseCollectionViewDataSource` in several ways to create custom UITableViews or UICollectionViews. For more information on how to create custom UITableViews, check out the following tutorial on [TutsPlus](http://code.tutsplus.com/tutorials/ios-sdk-crafting-custom-uitableview-cells--mobile-15702). For more information on how to create custom UICollectionViews, particularly how to implement a UICollectionViewLayout, check out the following tutorial on Ray Wenderlich in [Objective-C](http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12) and [Swift](http://www.raywenderlich.com/78550/beginning-ios-collection-views-swift-part-1).
132
+
133
+
### Using the Default UI*ViewCell Implementation
134
+
135
+
You can use the default `UITableViewCell` or `UICollectionViewCell` implementations to get up and running quickly. For `UITableViewCell`s, this allows for the `cell.textLabel` and the `cell.detailTextLabel` to be used directly out of the box. For `UICollectionViewCell`s, you will have to add subviews to the contentView in order for it to be useful.
136
+
137
+
#### Objective-C UITableView and UICollectionView with Default UI*ViewCell
// Populate cell as you see fit by adding subviews as appropriate
177
+
cell.contentView.addSubview(customView)
178
+
}
179
+
180
+
self.collectionView.dataSource=self.dataSource;
181
+
```
182
+
183
+
### Using Storyboards and Prototype Cells
184
+
185
+
Create a storyboard that has either a `UITableViewController`, `UICollectionViewController` or a `UIViewController` with a `UITableView` or `UICollectionView`. Drag a prototype cell onto the `UITableView` or `UICollectionView` and give it a custom reuse identifier which matches the reuse identifier being used when instantiating the `Firebase*ViewDataSource`. Drag and other properties onto the cell and associate them with properties of a `UITableViewCell` or `UICollectionViewCell` subclass. Code samples are similar to the above.
101
186
102
-
Create a custom subclass of UITableViewCell, with or without the XIB file. Make sure to instantiate `-initWithStyle: reuseIdentifier:` to instantiate the Cells. You can then hook the custom class up to the implementation of FirebaseTableViewDataSource.
187
+
### Using a Custom Subclass of UI*ViewCell
103
188
189
+
Create a custom subclass of `UITableViewCell` or `UICollectionViewCell`, with or without the XIB file. Make sure to instantiate `-initWithStyle: reuseIdentifier:` to instantiate a `UITableViewCell` or `-initWithFrame:` to instantiate a `UICollectionViewCell`. You can then hook the custom class up to the implementation of `FirebaseTableViewDataSource`.
190
+
191
+
#### Objective-C UITableView and UICollectionView with Custom Subclasses of UI*ViewCell
Create a custom XIB file and add it to the cell prototype. You can then use this like any other UITableViewCell, though with custom tags if desired.
239
+
Create a custom XIB file and hook it up to the prototype cell. You can then use this like any other UITableViewCell, either using custom tags or by using the custom class associated with the XIB.
118
240
241
+
#### Objective-C UITableView and UICollectionView with Custom XIB
// Use tags to populate custom properties, or use properties of a custom cell, if applicable
284
+
let yourCustomLabel: UILabel = cell.contentView.viewWithTag(<your-tag>) as! UILabel
285
+
yourCustomLabel.text= snap.key
286
+
}
287
+
288
+
self.collectionView.dataSource=self.dataSource;
289
+
```
290
+
134
291
## Understanding FirebaseUI's Internals
135
292
136
-
FirebaseUI has several building blocks that developers should understand before building additional functionality on top of FirebaseUI, including a synchronized array `FirebaseArray.*` and a generic data source superclass `FirebaseDataSource.*` from which FirebaseTableViewDataSource or other custom view classes subclass.
293
+
FirebaseUI has several building blocks that developers should understand before building additional functionality on top of FirebaseUI, including a synchronized array `FirebaseArray` and a generic data source superclass `FirebaseDataSource` from which `FirebaseTableViewDataSource` and `FirebaseCollectionViewDataSource` or other custom view classes subclass.
137
294
138
295
### FirebaseArray and the FirebaseArrayDelegate Protocol
139
296
140
-
FirebaseArray is synchronized array connecting a Firebase Ref with an array. It surfaces Firebase events through the FirebaseArrayDelegate Protocol. It is generally recommended that developers not directly access FirebaseArray without routing it through a custom data source.
297
+
`FirebaseArray` is synchronized array connecting a Firebase Ref with an array. It surfaces Firebase events through the FirebaseArrayDelegate Protocol. It is generally recommended that developers not directly access `FirebaseArray` without routing it through a custom data source, though if this is desired, check out `FirebaseDataSource` below.
let firebaseRef = Firebase(url: "https://<your-firebase-app>.firebaseio.com/")
308
+
let array = FirebaseArray(ref: firebaseRef)
146
309
```
147
310
148
311
### FirebaseDataSource
149
312
150
-
FirebaseDataSource acts as a generic data source by providing common information, such as the count of objects in the data source, and by requiring subclasses to implement FirebaseArrayDelegate methods as appropriate to the view. This class should never be instantiated, but should be subclassed when creating a specific adapter for a View. [FirebaseTableViewDataSource](https://github.com/firebase/FirebaseUI-iOS/blob/master/FirebaseUI/Implementation/FirebaseTableViewDataSource.m)is an example of this.
313
+
FirebaseDataSource acts as a generic data source by providing common information, such as the count of objects in the data source, and by requiring subclasses to implement FirebaseArrayDelegate methods as appropriate to the view. This class should never be instantiated, but should be subclassed when creating a specific adapter for a View. [FirebaseTableViewDataSource](https://github.com/firebase/FirebaseUI-iOS/blob/master/FirebaseUI/Implementation/FirebaseTableViewDataSource.m)and [FirebaseCollectionViewDataSource](https://github.com/firebase/FirebaseUI-iOS/blob/master/FirebaseUI/Implementation/FirebaseCollectionViewDataSource.m) are examples of this. FirebaseDataSource is essentially a wrapper around a FirebaseArray.
151
314
152
315
## Local Setup
153
316
@@ -165,6 +328,7 @@ $ ./setup.sh
165
328
-`git pull` to update the master branch
166
329
- tag and push the tag for this release
167
330
-`./build.sh` to build a binary
331
+
-`./create-docs.sh` to generate docs
168
332
- From your macbook that already has been granted permissions to FirebaseUI Cocoapods, do `pod trunk push`
169
333
- Update [firebase-versions](https://github.com/firebase/firebase-clients/blob/master/versions/firebase-versions.json) with the changelog for this release.
0 commit comments