grabury
grabury

Reputation: 5559

Collection view datasource methods not recognised

I changed the type of my controller from a collection view controller to a view controller and now the collection view datasource methods aren't recognised.

I replaced the collection view controller in my storyboard with the new view controller. I then added a collection view to the view controller. I controller dragged the collection view to set it as an outlet. I set the delegate and datasources.

I added the protocols with the class definition:

class MessagesViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate

I get the error "Method does not override any method from its superclass." on the line:

override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell

Upvotes: 1

Views: 670

Answers (1)

codester
codester

Reputation: 37189

You do not have to add override if your class implementing the protocol methods.Use override when you are overriding the methods of superclass.

Remove the override keyword from the definition.

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell 

Upvotes: 4

Related Questions