I need to create a custom layout based on http call to an api. Based on result from api in loop i will populate an array from CollectionView
In CustomLayout I need to use this array in order to draw correctly details in each row. In collectionView I use reload data after the data was added to array
Thank YOu
code:
class epgViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource{
var events = [Event]()
@IBOutlet weak var collectionView: UICollectionView!
//another initializations
. . .
//====== load Events ===============
func get_events() {
//http api call
//as result in loop i append data to Events()
self.events.append(newEvent)
//reload collection view data
self.collectionView.reloadData()
}
}
//////////
/// LAyout
////////
class customCollectionViewLayout: UICollectionViewLayout {
//prepare layout
override func prepareLayout() {
for section in 0...collectionView!.numberOfSections()-1 {
how to access array from collectionView
Events[i] ????
}
}
}