IBInspectable does not work for Int or UInt

1.2k views Asked by At
@IBInspectable  var numLines:UInt! = 2

The above code shows a message

Failed to set (numLines) user defined inspected property

UIViewNewClass [setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key numLines.

It does work with another IBInspectable property which is UIColor.

Does IBInspectable work with Int or UInt or am I doing something wrong here or it works only with NSNumber?

1

There are 1 answers

1
Jake On BEST ANSWER

It should work with Int, UInt, or any other numeric type. I've verified this locally with the code below:

@IBDesignable
class TestViewController: UIViewController {
    ...

    @IBInspectable var test: UInt = 0

    ...
}

This is showing up and working in interface builder as expected. I would make sure you have @IBDesignable on your class definition and also try doing a clean and deleting derived data.