Skip to content

Files

Latest commit

 

History

History
98 lines (61 loc) · 1.44 KB

valid_ibinspectable.md

File metadata and controls

98 lines (61 loc) · 1.44 KB

Pattern: Invalid @IBInspectable

Issue: -

Description

@IBInspectable should be applied to variables only, have its type explicit and be of a supported type.

Examples of correct code:

class Foo {
  @IBInspectable private var x: Int
}


class Foo {
  @IBInspectable private var x: String?
}


class Foo {
  @IBInspectable private var x: String!
}


class Foo {
  @IBInspectable private var count: Int = 0
}


class Foo {
  private var notInspectable = 0
}


class Foo {
  private let notInspectable: Int
}


class Foo {
  private let notInspectable: UInt8
}

Examples of incorrect code:

class Foo {
  @IBInspectable private let count: Int
}


class Foo {
  @IBInspectable privatevar insets: UIEdgeInsets
}


class Foo {
  @IBInspectable privatevar count = 0
}


class Foo {
  @IBInspectable privatevar count: Int?
}


class Foo {
  @IBInspectable privatevar count: Int!
}


class Foo {
  @IBInspectable privatevar x: ImplicitlyUnwrappedOptional<Int>
}


class Foo {
  @IBInspectable privatevar count: Optional<Int>
}


class Foo {
  @IBInspectable privatevar x: Optional<String>
}


class Foo {
  @IBInspectable privatevar x: ImplicitlyUnwrappedOptional<String>
}

Further Reading