Structures
The following structures are available globally.
-
Wrapped Date variables which constrain their values to the start of the enclosing interval
Usage example:
func demo_usingPropertyWrappers(_ date: Date) { @WholeHour var ymdHour = date @WholeHours var ymdHours = [date, date.addingTimeInterval(100000)] @WholeDay var ymDay = date @WholeMonth var yMonth = date print("date:", date.EEEE_ddMMyyyy_HHmmss) print("ymdHour:", ymdHour.EEEE_ddMMyyyy_HHmmss) print("ymdHours:", ymdHours.map {$0.EEEE_ddMMyyyy_HHmmss}) print("ymDay:", ymDay.EEEE_ddMMyyyy_HHmmss) print("yMonth:", yMonth.EEEE_ddMMyyyy_HHmmss) } let date = Date(timeIntervalSinceReferenceDate: 600000083) demo_usingPropertyWrappers(date)
Printed output:
See moredate: Monday 06.01.2020 11:41:23 ymdHour: Monday 06.01.2020 11:00:00 ymdHours: ["Monday 06.01.2020 11:00:00", "Tuesday 07.01.2020 15:00:00"] ymDay: Monday 06.01.2020 00:00:00 yMonth: Wednesday 01.01.2020 00:00:00
Declaration
Swift
@propertyWrapper public struct WholeMonth
-
Usage example: see WholeMonth
See moreDeclaration
Swift
@propertyWrapper public struct WholeDay
-
Usage example: see WholeMonth
See moreDeclaration
Swift
@propertyWrapper public struct WholeHour
-
Usage example: see WholeMonth
See moreDeclaration
Swift
@propertyWrapper public struct WholeHours
-
Declaration
Swift
public struct FileBackedDictionary<T> where T : Decodable, T : Encodable
-
Usage examples:
Sample usage:
See morefunc demo_TimerDeltaSigma() { var tds = TimerDeltaSigma() for _ in 0 ..< 10 { tds.printElapsedTimes() } print() for _ in 0 ..< 5 { tds.printElapsedTimes(.ms) } print() for _ in 0 ..< 5 { tds.printElapsedTimes(.s) } print() } ``` Sample output: ``` Δ 0.000000, Σ 0.000000 s Δ 0.000082, Σ 0.000082 s ... Δ 0.000022, Σ 0.000260 s Δ 0.000021, Σ 0.000281 s Δ 0.000, Σ 0.000 s ... Δ 0.000, Σ 0.000 s Δ 0, Σ 0 s ... Δ 0, Σ 0 s ```
Declaration
Swift
public struct TimerDeltaSigma
-
Usage notes: CodableUserDefault
vs. PlistUserDefault PlistUserDefault supports plist-compatible types: Data, String, Number, Date, Array and Dictionary.
CodableUserDefault supports any type conforming to the Codable protocol (which includes plist-compatible types, but also structs and enums conforming to Codable.
Note: PlistUserDefault must be used for settings declared in Settings.bundle/Root.plist (because these are stored in type-specific formats, while CodableUserDefault stores/retrieves all types as Data).
See moreDeclaration
Swift
@propertyWrapper public struct CodableUserDefault<Key, Value> where Key : RawRepresentable, Value : Decodable, Value : Encodable, Key.RawValue == String
-
Wrapper PlistUserDefault
See moreenables creation of variables of any .plist-compatible type (Data, String, Number, Date, Array and Dictionary) Declaration
Swift
@propertyWrapper public struct PlistUserDefault<Key, Value> where Key : RawRepresentable, Key.RawValue == String