1

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

1 Answer 1

4

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 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.