objective-cswifticarousel

iCarousel in swift version 1.2 error (candidate is not Objc but protocol requires it)


I get the following error in swift 1.2 : 'RootViewController' does not conform to protocol 'iCarouselDataSource'

In the below class, when I tryed to implement the third party library iCarousel:

class RootViewController: UIViewController,iCarouselDataSource,iCarouselDelegate
{...}

The auto-fix tool puts an @objc mark in this method that conform the protocol:

@objc func carousel(carousel: iCarousel!, viewForItemAtIndex index: Int, var reusingView view: UIView?) -> UIView?
{}

But then another error appears : Method cannot be marked @objc because the type of the parameter 3 cannot be represented in Objective-C

I appreciate any help or clue, thanks !


Solution

  • Remove var from reusingView, ex:

    func carousel(carousel: iCarousel!, viewForItemAtIndex index: Int, reusingView view: UIView!) -> UIView! {
        var newView = view
        if newView == nil {
            //create new view
        }
        //update data
        return newView
    }