Skip to content

Commit e2c3330

Browse files
committed
Fixes default datasources implementation. ReactiveX#825
1 parent bfb9441 commit e2c3330

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

RxCocoa/Common/DelegateProxyType.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ extension DelegateProxyType {
178178
let maybeProxy = Self.assignedProxyFor(object) as? Self
179179

180180
let proxy: Self
181-
if maybeProxy == nil {
181+
if let existingProxy = maybeProxy {
182+
proxy = existingProxy
183+
}
184+
else {
182185
proxy = Self.createProxyForObject(object) as! Self
183186
Self.assignProxy(proxy, toObject: object)
184187
assert(Self.assignedProxyFor(object) === proxy)
185188
}
186-
else {
187-
proxy = maybeProxy!
188-
}
189189

190190
let currentDelegate: AnyObject? = Self.currentDelegateFor(object)
191191

RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ let collectionViewDataSourceNotSet = CollectionViewDataSourceNotSet()
1919
class CollectionViewDataSourceNotSet
2020
: NSObject
2121
, UICollectionViewDataSource {
22+
23+
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
24+
return 0
25+
}
26+
2227
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
2328
rxAbstractMethodWithMessage(dataSourceNotSet)
2429
}

RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class TableViewDataSourceNotSet
2020
: NSObject
2121
, UITableViewDataSource {
2222
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
23-
rxAbstractMethodWithMessage(dataSourceNotSet)
23+
return 0
2424
}
2525

2626
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
@@ -63,7 +63,7 @@ public class RxTableViewDataSourceProxy
6363
Required delegate method implementation.
6464
*/
6565
public func numberOfSectionsInTableView(tableView: UITableView) -> Int {
66-
return (_requiredMethodsDataSource ?? tableViewDataSourceNotSet).numberOfSectionsInTableView?(tableView) ?? 1
66+
return (_requiredMethodsDataSource ?? tableViewDataSourceNotSet).numberOfSectionsInTableView?(tableView) ?? 0
6767
}
6868

6969
/**

0 commit comments

Comments
 (0)