Kingfisher: Self is immutable inside class extension

Created on 11 Dec 2018  Â·  2Comments  Â·  Source: onevcat/Kingfisher

Check List

Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.

Issue Description

What

After upgrading from 4.x to 5.x, it's no longer possible to set the 'indicatorType' inside of a class extension.

Cannot assign to property: 'self' is immutable

Reproduce

Create a UIImageView extension and try to set the indicatorType inside a function.

extension UIImageView {
  func doSomething() {
    self.kf.indicatorType = .activity // Error
  }
}

Other Comment

It's still possible to call functions such as 'setImage'.

Most helpful comment

Yes, now the kf returns a struct instead of class. This change is for performance, and for your case, try:

extension UIImageView {
    func doSomething() {
        var kf = self.kf
        kf.indicatorType = .activity
    }
}

All 2 comments

Yes, now the kf returns a struct instead of class. This change is for performance, and for your case, try:

extension UIImageView {
    func doSomething() {
        var kf = self.kf
        kf.indicatorType = .activity
    }
}

Yes, this fixes the compilation error.
I was worried that the changes would not be reflected, but it seems to work.

Thanks for the help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nickgate picture nickgate  Â·  4Comments

jacowu picture jacowu  Â·  4Comments

kbpontius picture kbpontius  Â·  3Comments

sindresorhus picture sindresorhus  Â·  3Comments

litt1e-p picture litt1e-p  Â·  4Comments