The implementation of Ns_option in OBJC in Swift is achieved not through enum, but through conform Rawoptionsettype protocol's struct.
The code is as follows:
struct Test : RawOptionSetType {
typealias RawValue = UInt
private var value: UInt = 0
init(_ value: UInt) { self.value = value }
init(rawValue value: UInt) { self.value = value }
init(nilLiteral: ()) { self.value = 0 }
static var allZeros: Test { return self(0) }
static func fromMask(raw: UInt) -> Test { return self(raw) }
var rawValue: UInt { return self.value }
static var None: Test { return self(0) }
static var T1: Test { return Test(1 << 0) }
static var T2: Test { return Test(1 << 1) }
}
Viewing Rawoptionsettype will find that there are equable and Bitwiseoperationstype not implemented. This is actually the SWIFT standard library through the generic implementation can refer to this article on the Nshipster
Although Apple's approach to implementing these protocols with generic global functions reduces boilerplate code (boilerplate), there are many boilerplate in this struct. Here is a swift option generator
Swift implements bitmask Option (Enum)