Fixes default datasources implementation. #825

This commit is contained in:
Krunoslav Zaher 2016-08-07 15:12:01 +02:00
parent bfb9441414
commit e2c3330d61
3 changed files with 11 additions and 6 deletions

View File

@ -178,14 +178,14 @@ extension DelegateProxyType {
let maybeProxy = Self.assignedProxyFor(object) as? Self
let proxy: Self
if maybeProxy == nil {
if let existingProxy = maybeProxy {
proxy = existingProxy
}
else {
proxy = Self.createProxyForObject(object) as! Self
Self.assignProxy(proxy, toObject: object)
assert(Self.assignedProxyFor(object) === proxy)
}
else {
proxy = maybeProxy!
}
let currentDelegate: AnyObject? = Self.currentDelegateFor(object)

View File

@ -19,6 +19,11 @@ let collectionViewDataSourceNotSet = CollectionViewDataSourceNotSet()
class CollectionViewDataSourceNotSet
: NSObject
, UICollectionViewDataSource {
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 0
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
rxAbstractMethodWithMessage(dataSourceNotSet)
}

View File

@ -20,7 +20,7 @@ class TableViewDataSourceNotSet
: NSObject
, UITableViewDataSource {
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
rxAbstractMethodWithMessage(dataSourceNotSet)
return 0
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
@ -63,7 +63,7 @@ public class RxTableViewDataSourceProxy
Required delegate method implementation.
*/
public func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return (_requiredMethodsDataSource ?? tableViewDataSourceNotSet).numberOfSectionsInTableView?(tableView) ?? 1
return (_requiredMethodsDataSource ?? tableViewDataSourceNotSet).numberOfSectionsInTableView?(tableView) ?? 0
}
/**