I'm getting the following error when compile swift application (iOS 8.1)
Type 'ViewController' does not conform to protocol 'UICollectionViewDataSource'
at "class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate" line
I've just checked few posts here but no one helps me to solve this problem.
Here's the code of ViewController.swift file:
import UIKit
class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
var tableDescription: [String] = []
var tableNumbers: [String] = []
override func viewDidLoad() {
super.viewDidLoad()
self.populateView()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func collectionView(collectionView: UICollectionView, numberOfItemInSection section: Int) -> Int{
return tableDescription.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell{
let cell: CollViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as CollViewCell
cell.lblDescription.text = tableDescription[indexPath.row]
cell.lblNumber.text = tableNumbers[indexPath.row]
return cell
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
println("Cell \(indexPath.row) selected")
}
}
Thank you so much helping me.
Check for typos in your code, Like - use "numberOfItemsInSection"instead numberOfItemInSection.