Skip to content

Commit 9fbf3aa

Browse files
committed
Fixes examples in README.md
1 parent bd56cb4 commit 9fbf3aa

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ Writing table and collection view data sources is tedious. There is a large numb
2626
RxSwift helps alleviate some of the burden with a simple data binding mechanism:
2727
1) Turn your data into an Observable sequence
2828
2) Bind the data to the tableView/collectionView using one of:
29-
- `rx_items(dataSource:protocol<RxTableViewDataSourceType, UITableViewDataSource>)`
30-
- `rx_items(cellIdentifier:String)`
31-
- `rx_items(cellIdentifier:String:Cell.Type:_:)`
32-
- `rx_items(_:_:)`
29+
- `rx.items(dataSource:protocol<RxTableViewDataSourceType, UITableViewDataSource>)`
30+
- `rx.items(cellIdentifier:String)`
31+
- `rx.items(cellIdentifier:String:Cell.Type:_:)`
32+
- `rx.items(_:_:)`
3333

3434
```swift
35-
let dataSource = Observable<[String]>.just(["first element", "second element", "third element"])
35+
let data = Observable<[String]>.just(["first element", "second element", "third element"])
3636

37-
dataSource.bindTo(tableView.rx.items(cellIdentifier: "Cell")) { index, model, cell in
37+
data.bindTo(tableView.rx.items(cellIdentifier: "Cell")) { index, model, cell in
3838
cell.textLabel?.text = model
3939
}
4040
.addDisposableTo(disposeBag)
@@ -47,7 +47,8 @@ These are precisely the use cases that RxDataSources helps solve.
4747
With RxDataSources, it is super easy to just write
4848

4949
```swift
50-
Observable.just([MySection(header: "title", items: [1, 2, 3])])
50+
let dataSource = RxTableViewSectionedReloadDataSource<SectionModel<String, Int>>()
51+
Observable.just([SectionModel(model: "title", items: [1, 2, 3])])
5152
.bindTo(tableView.rx.items(dataSource: dataSource))
5253
.addDisposableTo(disposeBag)
5354
```
@@ -95,7 +96,7 @@ let dataSource = RxTableViewSectionedReloadDataSource<SectionOfCustomData>()
9596

9697
```swift
9798
dataSource.configureCell = { ds, tv, ip, item in
98-
let cell = tv.dequeueReusableCellWithIdentifier("Cell", forIndexPath: ip)
99+
let cell = tv.dequeueReusableCell(withIdentifier: "Cell", for: ip)
99100
cell.textLabel?.text = "Item \(item.anInt): \(item.aString) - \(item.aCGPoint.x):\(item.aCGPoint.y)"
100101
return cell
101102
}

0 commit comments

Comments
 (0)