๐ ฟ๏ธOptionSet
ๅฆๆ่ฎๆธ็่ก็บๅใๅฎ้ธ้กใ๏ผๅฏ่ๆ ฎ็จ enumใ
ๅฆๆ้กไผผใๅค้ธ้กใ๏ผๅฏ่ๆ ฎ็จ OptionSetใ
When creating an option set, include a rawValue
property in your type declaration. For your type to automatically receive default implementations for set-related operations, the rawValue
property must be of a type that conforms to the FixedWidthInteger
protocol, such as Int
or UInt8
.
Next, create unique options as static properties of your custom type using unique powers of two (1, 2, 4, 8, 16 ...) for each individual propertyโs raw value so that each property can be represented by a single bit of the typeโs raw value.
โญ๏ธ ๆณจๆ๏ผOptionSet ็ methods ้็ถ็่ตทไพๅๆฏๅ ็ด ่้ๅ้็็จ่ช (ๆบ่ชๆผ SetAlgebra)๏ผไฝ่ฆๆณจๆๆฏๅ OptionSet ็ static properties ๆฌ่ณชไธ้ๆฏไธๅใ้ๅใ็ๆฆๅฟต๏ผๅฐฑ็ฎๅชๅ ๅซไธๅๅ ็ด ้ฝๆฏๅฆๆญค๏ผ
Last updated