@@ -54,7 +54,8 @@ extension ObservableCollectionType where Collection.Index == Int {
5454
5555public class RKCollectionViewDataSource < C: ObservableCollectionType where C. Collection. Index == Int > : NSObject , UICollectionViewDataSource {
5656
57- private let collection : C
57+ private let observableCollection : C
58+ private var sourceCollection : C . Collection
5859 private weak var collectionView : UICollectionView !
5960 private let createCell : ( NSIndexPath , C . Collection , UICollectionView ) -> UICollectionViewCell
6061 private weak var proxyDataSource : RKCollectionViewProxyDataSource ?
@@ -64,15 +65,17 @@ public class RKCollectionViewDataSource<C: ObservableCollectionType where C.Coll
6465 self . collectionView = collectionView
6566 self . createCell = createCell
6667 self . proxyDataSource = proxyDataSource
67- self . collection = collection
68+ self . observableCollection = collection
69+ self . sourceCollection = collection. collection
6870 self . animated = animated
6971 super. init ( )
7072
7173 collectionView. dataSource = self
7274 collectionView. reloadData ( )
7375
74- collection . observe ( on: ImmediateOnMainExecutionContext) { [ weak self] event in
76+ observableCollection . observe ( on: ImmediateOnMainExecutionContext) { [ weak self] event in
7577 if let uSelf = self {
78+ uSelf. sourceCollection = event. collection
7679 if animated {
7780 uSelf. collectionView. performBatchUpdates ( {
7881 RKCollectionViewDataSource . applyRowUnitChangeSet ( event, collectionView: uSelf. collectionView, sectionIndex: 0 , dataSource: uSelf. proxyDataSource)
@@ -109,11 +112,11 @@ public class RKCollectionViewDataSource<C: ObservableCollectionType where C.Coll
109112 }
110113
111114 @objc public func collectionView( collectionView: UICollectionView , numberOfItemsInSection section: Int ) -> Int {
112- return collection . collection . count
115+ return sourceCollection . count
113116 }
114117
115118 @objc public func collectionView( collectionView: UICollectionView , cellForItemAtIndexPath indexPath: NSIndexPath ) -> UICollectionViewCell {
116- return createCell ( indexPath, collection . collection , collectionView)
119+ return createCell ( indexPath, sourceCollection , collectionView)
117120 }
118121
119122 @objc public func collectionView( collectionView: UICollectionView , viewForSupplementaryElementOfKind kind: String , atIndexPath indexPath: NSIndexPath ) -> UICollectionReusableView {
0 commit comments