I'm suddenly having a strange and reproducible error when using an @IBDesignable class, @IBInspectable properties are giving the following warning:
Main.storyboard: warning: IB Designables: Ignoring user defined runtime attribute for key path "test" on instance of "UIButton". Hit an exception when attempting to set its value: [ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key test.
To be clear this warning is only a problem in Xcode, it packages fine. Still annoying!
Steps to reproduce
- Create new project
Create a custom @IBDesignable UIButton subclass, with an @IBInspectable String property:
import UIKit @IBDesignable class TempButton: UIButton { @IBInspectable var test:String = "" }
- Drag a Button to a View Controller in the storyboard, and give it the custom class "TempButton" in the Identity Inspector.
- Now the 'Test' attribute should appear in the Attributes Inspector for 'Temp Button' properties - type anything into this field.
- Bam! The above warning appears. Remove the text from the field, and the warning disappears.
I've tried several solutions - different variable names, making the 'test' property an Optional, using an initializer, no luck so far.
Here is a screen capture of the problem: