An open source library with some useful extensions and utilities for the core Foundation
Swift libraries. Developed as re-usable components for various projects at
XII’s iOS, macOS, and watchOS applications.
Installation
Swift Package Manager
In Xcode, select File > Swift Packages > Add Package Dependency.
Follow the prompts using the URL for this repository
Select the SwiftFoundationExtensions library to add to your project
var startOfWeek: Date { get }
var daysRemainingThisWeek: Int { get }
var startOfMonth: Date { get }
var startOfYear: Date { get }
init(year: Int, month: Int, day: Int)
func isCloseTo(_ other: Double) -> Bool
func isCloseToOrGreaterThan(_ other: Double) -> Bool
func isCloseToOrLessThan(_ other: Double) -> Bool
var roundedUp: Int { get }
var roundedDown: Int { get }
func sum() async rethrows -> Double where Element == Double
func sumOfSquares() async rethrows -> Double where Element == Double
func sum() async rethrows -> Int where Element == Int
func sumOfSquares() async rethrows -> Int where Element == Int
mutating func increment(key: Key, by value: Value) where Value == Int
mutating func increment(key: Key) where Value == Int
mutating func decrement(key: Key) where Value == Int
mutating func increment(key: Key, by value: Value) where Value == Double
mutating func increment(key: Key) where Value == Double
mutating func decrement(key: Key) where Value == Double
mutating func incrementSubMapValue<SubKey : Hashable>(
key: Key,
subKey: SubKey,
by value: Int
) where Value == Dictionary<SubKey, Int>
mutating func incrementSubMapValue<SubKey : Hashable>(
key: Key,
subKey: SubKey
) where Value == Dictionary<SubKey, Int>
mutating func decrementSubMapValue<SubKey : Hashable>(
key: Key,
subKey: SubKey
) where Value == Dictionary<SubKey, Int>
mutating func incrementSubMapValue<SubKey : Hashable>(
key: Key,
subKey: SubKey,
by value: Double
) where Value == Dictionary<SubKey, Double>
mutating func incrementSubMapValue<SubKey : Hashable>(
key: Key,
subKey: SubKey
) where Value == Dictionary<SubKey, Double>
mutating func decrementSubMapValue<SubKey : Hashable>(
key: Key,
subKey: SubKey
) where Value == Dictionary<SubKey, Double>
mutating func append<InnerValue>(
value: InnerValue,
for key: Key
) where Value == Array<InnerValue>
func inverted() -> [Value: Key] where Value : Hashable
func inverted() -> [Value.Element: [Key]]
where Value : Sequence, Value.Element : Hashable
mutating func set<SubKey : Hashable, SubValue>(
value: SubValue,
key: Key,
subKey: SubKey
) where Value == Dictionary<SubKey, SubValue>
A utility for tracking/reporting the elapsed time between operations.
Utilizes CFAbsoluteTimeGetCurrent to get an accurate measure of the current time on the device and the difference
between these measures as the elapsed time.
SwiftFoundationExtensions Library
An open source library with some useful extensions and utilities for the core
Foundation
Swift libraries. Developed as re-usable components for various projects at XII’s iOS, macOS, and watchOS applications.Installation
Swift Package Manager
SwiftFoundationExtensions
library to add to your projectLicense
See the LICENSE file.
Included Extensions / API
Informational (Source)
Full version and build number of the main bundle in the format:
v[MAJOR].[MINOR].[PATCH]-[BUILD]
True if the main bundle was installed from the app store (not in a sandbox environment), false otherwise.
Date
Extensions (Source)Comparable
Extensions (Source)Double
Extensions (Source)Sequence
Extensions (Source)EnumeratedSequence
Extensions (Source)Collection
Extensions (Source)AsyncSequence
Extensions (Source)Dictionary
Extensions (Source)Logger
Extensions (Source)ErrorWithTrace
struct (Source)A Specialized
Error
that captures the file/line number of a thrown error to aid in debugging.Conforms to:
Error
andCustomStringConvertible
Error
Extensions (Source)ElapsedTimer
Utility (Source)A utility for tracking/reporting the elapsed time between operations.
Utilizes
CFAbsoluteTimeGetCurrent
to get an accurate measure of the current time on the device and the difference between these measures as the elapsed time.