gotnull
gotnull

Reputation: 27214

Subclass UICollectionViewCell in Swift 1.2

Given the following UICollectionViewCell subclass:

class MJCollectionViewCell: UICollectionViewCell {

    var MJImageView: UIImageView!
    var image = UIImage()

    override init(frame: CGRect) {
        super.init(frame: frame)
    }

    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

    // MARK: - Setters

    func setImage(image: UIImage) {
        self.MJImageView.image = image
    }
}

I receive the following error on func setImage(image: UIImage):

Method 'setImage' redeclares Objective-C method 'setImage:'

Upvotes: 0

Views: 1710

Answers (1)

Dejan Skledar
Dejan Skledar

Reputation: 11435

You have to rename the methond setImage(image: UIImage), because there is already a method with this name declared in the Objective-C's UICollectionViewCell class.

Upvotes: 3

Related Questions