Structures
The following structures are available globally.
-
An
OSUnfairLock
is a wrapper around an unfair lock that locks around accesses to a stored object. It has the same API asOSAllocatedUnfairLock
.Despite being a
struct
, it isn’t a value type, as copied instances control the same underlying lock allocation.Prefer storing state protected by the lock in
State
. Containing locked state inside the lock helps track what is protected state and provides a scope where it is safe to access that state.When using
OSUnfairLock
with external state, nonscoped locking allows more flexible locking patterns by usinglock()
/unlock()
, but offers no assistance in tracking what state is protected by the lock.This lock must be unlocked from the same thread that locked it. As such, it is unsafe to use
lock()
/unlock()
across anawait
suspension point. Instead, usewithLock
to enforce that the lock is only held within a synchronous scope.If you are using a lock from asynchronous contexts only, prefer using an actor instead.
This lock is not a recursive lock. Attempting to lock it again from the same thread while the lock is already locked will crash.
See moreDeclaration
Swift
public struct OSUnfairLock<State> : @unchecked Sendable
-
A type that conforms to
See moreDynamicProperty
to facilitate automatically updating SwiftUIView
s.Declaration
Swift
@available(iOS 13, tvOS 13, watchOS 6, macOS 10.15, *) @propertyWrapper public struct PersistStorage<Value> : DynamicProperty
-
A transformer that aggregates multiple transformers. Multiple aggregate transformers can be chained.
See moreDeclaration
Swift
public struct AggregateTransformer<Input, Output> : Transformer
-
A transformer that transformers values to JSON data.
See moreDeclaration
Swift
public struct JSONTransformer<Input> : Transformer where Input : Decodable, Input : Encodable
-
A transformer that transformers values to property list data.
See moreDeclaration
Swift
public struct PropertyListTransformer<Input> : Transformer where Input : Decodable, Input : Encodable
-
A Transformer that transforms
See moreRawRepresentable
types.Declaration
Swift
public struct RawRepresentableTransformer<Type> : Transformer where Type : RawRepresentable