Here is the code, where i set DataSource for CollectionView:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
collectionView.dataSource = ProductDataSource(products: createAllProductsList())
collectionView.reloadData()
}
DataSource class is conform to UICollectionViewDataSource protocol. Code compiles with no troubles. But i see empty collection view instead of my 5 elements. ReloadData don't trigger methods from DataSource.
Swift 3, XCode 8
Create an instance variable of ProductDataSource in the current class and then set it as data source that will fix the issue. The object does not have a strong pointer to it in the current case and hence the data source gets nullified.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.