Skip to main content

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 preconditionFailure when accessing the property before it is set and when attempting to set an already set property when the resettable flag is set to false.

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

NameDescription
descriptionA message to be displayed if the property is accessed/modified incorrectly
resettablewhether or not the property can be modified after the initial setting.