[Swift] UIAccessibilityTraits 초기화가 이상한데요? (feat. OptionSet에 대하여)

왜 단일 값으로도 생성되고, array로도 생성되시는지..???

기존 상황

func setAccessibility(traits: UIAccessibilityTraits) {
self.accessibilityTraits = traits
}
view.setAccessibility(traits: .button)

추가 요구 사항

func setAccessibility(traits: UIAccessibilityTraits...)

어쩌다 마주친 Build Succeeded

view.setAccessibility(traits: [.button, .selected])

OptionSet (protocol)

Using an Option Set Type

let singleOption: ShippingOptions = .priority
let multipleOptions: ShippingOptions = [.nextDay, .secondDay, .priority]
let noOptions: ShippingOptions = []
view.setAccessibility(traits: .button)
view.setAccessibility(traits: [.button, .selected])
var freeOptions: ShippingOptions = .nextDay
freeOptions.insert(.priority)

마무리

참고

 https://github.com/sujinnaljin/TIL