I have code like this:
@IBInspectable var myProperty: String? {
set(newValue) {
//logic for setter
}
get {
return myProperty
}
}
The above code generates a warning:
Attempting to access 'myProperty' within its own getter. Access 'self' explicitly to silence this warning.
So I fix the code as suggested:
@IBInspectable var myProperty: String? {
set(newValue) {
//logic for setter
}
get {
return self.myProperty
}
}
The problem would be solved but I am using SwiftFormat during the application build phase. And SwiftFormat automatically removes the self keyword, treating it as unnecessary here.
I see two solutions:
- Turn off the redundantSelf rule in SwiftFormat.
- Modify (how?) the code to be acceptable for both the compiler and the SwiftFormat.
What would be the best choice for this?