From a4d9ee4b6a1cca0d2ea3b4496793c4bf17f8644d Mon Sep 17 00:00:00 2001 From: tqtifnypmb Date: Sun, 2 Dec 2018 14:56:59 +0800 Subject: [PATCH 1/2] crash caused by changing dataSource from nonnull to null --- Sources/FSPagerView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/FSPagerView.swift b/Sources/FSPagerView.swift index 7fb17d9..ba3219f 100644 --- a/Sources/FSPagerView.swift +++ b/Sources/FSPagerView.swift @@ -315,6 +315,7 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega public func numberOfSections(in collectionView: UICollectionView) -> Int { guard let dataSource = self.dataSource else { + self.numberOfItems = 0 return 1 } self.numberOfItems = dataSource.numberOfItems(in: self) From 6e5773400895321cf49b68feb33a27b0a09c8911 Mon Sep 17 00:00:00 2001 From: tqtifnypmb Date: Sun, 2 Dec 2018 15:00:55 +0800 Subject: [PATCH 2/2] crash caused by changing dataSource from nonnull to null --- Sources/FSPagerView.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/FSPagerView.swift b/Sources/FSPagerView.swift index ba3219f..4d2b636 100644 --- a/Sources/FSPagerView.swift +++ b/Sources/FSPagerView.swift @@ -315,8 +315,7 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega public func numberOfSections(in collectionView: UICollectionView) -> Int { guard let dataSource = self.dataSource else { - self.numberOfItems = 0 - return 1 + return 0 } self.numberOfItems = dataSource.numberOfItems(in: self) guard self.numberOfItems > 0 else {