Reputation: 5559
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
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