Search code examples
iosswiftiboutletcollectionviewuicollectionviewflowlayout

Errors when creating an IBOutlet from UICollectionViewFlowLayout from storyboard


I am trying to set an IBOutlet from my collection view's flow layout property (Which is in a collectionViewController):

@IBOutlet weak var collectionViewLayout: UICollectionViewFlowLayout!

however, when I connect the outlet, I get these 3 errors:

  • Cannot override 'strong' property with 'weak' property
  • Getter for 'collectionViewLayout' with Objective-C selector 'collectionViewLayout' conflicts with getter for 'collectionViewLayout' from superclass 'UICollectionViewController' with the same Objective-C selector
  • Property 'collectionViewLayout' with type 'UICollectionViewFlowLayout?' cannot override a property with type 'UICollectionViewLayout'

Would someone please explain what this means and how I can fix it?


Solution

  • collectionViewLayout is a property of the UICollectionViewController class. Change outlet name to something else.