RequiredOnce
STRUCT
RequiredOnce
public struct RequiredOnce<T>
A property wrapper that requires a value to be set once.
Properties
wrappedValue
public var wrappedValue: T
The RequiredOnce wrapped value
- Note: This will throw a
preconditionFailurewhen accessing the property before it is set and when attempting to set an already set property when theresettableflag is set tofalse.
Methods
init(description:resettable:)
public init(description: String, resettable: Bool = false)
Constructs the RequiredOnce property wrapper
- Parameters:
- description: A message to be displayed if the property is accessed/modified incorrectly
- resettable: whether or not the property can be modified after the initial setting.
Parameters
| Name | Description |
|---|---|
| description | A message to be displayed if the property is accessed/modified incorrectly |
| resettable | whether or not the property can be modified after the initial setting. |