Chinmay Balutkar
Chinmay Balutkar

Reputation: 234

Error that UITableViewCell with IBOutlet named `imageView` conflicts with superclass IBOutlet

I have made a custom UITableViewCell in which I have added 2 labels and one UIImageView, each with IBOutlets.

IBOutlet weak var imageView: UIImageView!

I've given the UIImageView an IBOutlet named imageView, but after adding it I am getting error:

Getter for 'imageView' with Objective-C selector 'imageView' conflicts with getter for 'imageView' from superclass 'UITableViewCell' with the same Objective-C selector"

enter image description here

How can I fix this error? Is there any way to use an IBOutlet named imageView in a UITableViewCell subclass?

Upvotes: 5

Views: 3450

Answers (3)

Priya
Priya

Reputation: 349

You are getting this error since UITableViewCell has its own imageView property and you are making an outlet of name imageView which will conflict with its super class(UITableViewCell) property name(imageView) which is a getter method. So, you just need to change the name of the outlet.

Upvotes: 17

Saheb Roy
Saheb Roy

Reputation: 5957

Change the name of the outlet as everyone is suggesting, as tableviewCell has its own imageView property, so when you are assigning another outlet with the name of imageView the getter methods are getting conflicted

Upvotes: 3

K. Michał
K. Michał

Reputation: 1053

You need to change its name f.e. to photoView. Now it is overriding property from it's super class which is imageView.

Upvotes: 2

Related Questions