Search code examples
iosswiftuicollectionviewuicollectionviewcellgemini

Cannot override mutable property 'collectionView' of type 'UICollectionView?' with covariant type 'GeminiCollectionView?'


I have had a custom collection view and everything worked fine. I wanted to include 'Gemini' to make beautiful animations when sliding my cells horizontally. I believe that the problem is not Gemini, I think the same would have happen with changing VC class to any other one, but I dont know how to solve this because I never faced with this before, is there a shortcut from this?

I have installed and imported the pod into code.
I had a UICollectionViewController but to work with gemini I needed to connect my collectionView from Storyboard to ViewController. Before that, I have put a class in Storyboard for my CollectionView to be GeminiCollectionView like in the image below:
Storyboard coll.view class

After that, I changed a class for my CollectionView in ViewController, too, like in the image below and got those three errors:
enter image description here

In the later code, it doesnt show any errors:
viewDidLoad

collectionView.gemini
            .rollRotationAnimation()
            .degree(45)
            .rollEffect(.rollUp)


cellForItemAt

self.collectionView.animateCell(cell)


scrollViewDidScroll

self.collectionView.animateVisibleCells()


willDisplay cell

if let cell = cell as? RatingCell {
//RatingCell inhertis the GeminiCell class
            self.collectionView.animateCell(cell)
        }

So, all the code is fine except the declaration as I mentioned at the beginning and here:

@IBOutlet var collectionView: GeminiCollectionView!



Waiting for random guys to unvote this :P


Solution

  • Solved

    @IBOutlet var collectionView: GeminiCollectionView!
    

    That line was a problem. Seems like you mustn't default Swift's name to override mutable property, which is collectionView for Collection Views and tableView for Table Views.
    I changed that line to

    @IBOutlet var collView: GeminiCollectionView!
    

    ...and the errors disappeared.