RSDStringLiteralOptionSet
public protocol RSDStringLiteralOptionSet : OptionSet, Codable
RSDStringLiteralOptionSet extends OptionSet to allow mapping any OptionSet that uses a BinaryInteger
as its RawValue to a set of string keys.
Seealso
RSDActiveUICommand for example usage.
-
A mapping of an option to a string value. This is used to allow
Codableprotocol conformance using human-readable strings rather thanBinaryflags.Declaration
Swift
static var stringMapping: [String : RawValue] -
A convenience method for mapping a
rawValueto aString.Declaration
Swift
static func set(rawValue: RawValue, forKey: String)Parameters
rawValueThe raw value for this command.
forKeyThe string representation.
-
init(_:codingKey:)Extension methodInitialize a option step value using both the binary raw value and the coding key to use when coding the value.
Declaration
Swift
public init(_ rawValue: RawValue, codingKey: String)Parameters
rawValueThe raw value for this command.
codingKeyThe string representation.
-
init(from:stringMapping:)Extension methodCreates a new instance by decoding from the given decoder.
This initializer throws an error if reading from the decoder fails, or if the data read is corrupted or otherwise invalid.
Declaration
Swift
public init(from decoder: Decoder, stringMapping: [String : RawValue]) throwsParameters
decoderThe decoder to read data from.
stringMappingThe mapping of coding strings to the associated raw value.
-
encode(to:)Extension methodMethod for encoding the value back into an array of strings.
Declaration
Swift
public func encode(to encoder: Encoder) throwsParameters
encoderThe encoder to encode this value to.
View on GitHub
RSDStringLiteralOptionSet Protocol Reference