diff --git a/RxCocoa/Common/DelegateProxyType.swift b/RxCocoa/Common/DelegateProxyType.swift index 82cd79bb..d42c01df 100644 --- a/RxCocoa/Common/DelegateProxyType.swift +++ b/RxCocoa/Common/DelegateProxyType.swift @@ -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) diff --git a/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift b/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift index eaa3f2ba..5614450c 100644 --- a/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift +++ b/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift @@ -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) } diff --git a/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift b/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift index 30d4011a..6eaf319c 100644 --- a/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift +++ b/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift @@ -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 } /**