Ios – Cannot override mutable property ‘refreshControl’ of type ‘UIRefreshControl?’ with covariant type ‘UIRefreshControl’

iosswiftuirefreshcontroluitableview

I use a UIRefreshControl in my tableview for pull new data. But when I define the control, below error shows. I've googled for a while, but find nothing useful.

I use Xcode Version 9.2 (9C40b), swift4, IOS11.2

Cannot override mutable property 'refreshControl' of type
'UIRefreshControl?' with covariant type 'UIRefreshControl'

var refreshControl = UIRefreshControl()

enter image description here

Best Answer

If you want to define another control, then change the name... refreshControl is a UIScrollView/UITableViewController ivar since iOS10/iOS6 [respectively]. You're trying to redefine it and that is what causing the error. Or you can use the supplied one of course.

You probably meant something like self.refreshControl = UIRefreshControl()

Related Topic