I'm trying to create a OptionSet which can be used in combination with @IBInspectable It seems like this was possible in Swift 2.2
I came across this library which seems to be using an OptionSet in combination with @IBInspectable (The IBInspectable is being the first one set and the structure is actually created on the bottom of the class)
I think it was possible because of the BooleanType which seems to be removed since Swift 2.3
I wrote my OptionSet like this but it doesn't work in combination with @IBInspectable because it's not supported where the BooleanType was (I think that is why it did work in the code of the earlier mentioned library)
public struct Shapes: OptionSet {
private enum Shape: Int, CustomStringConvertible {
case Circle=1, Square=2
public var description: String {
var shift = 0
while (rawValue >> shift != 1) { shift += 1 }
return ["Circle", "Square"][shift]
}
}
public let rawValue: Int
public init(rawValue: Int) { self.rawValue = rawValue }
private init(_ shape: Shape) { self.rawValue = shape.rawValue }
static let Circle = Shapes(Shape.Circle)
static let Square = Shapes(Shape.Square)
}
Does anyone know how to make sure that it will work in Swift 3
So I did find a way to be able to use it by writing some sort of adapter.
I'm pretty sure it can be done better and if anyone has a way to do so don't hesitate to provide your solution but this is how I did it right now
Then my
@IBInspectablelooks like this