SwiftFoundation is a collection of useful extensions and utilities for the Swift programming language. This library provides a variety of enhancements to existing Swift types, making common tasks more convenient and efficient. It also includes features for working with URLs, HTTP requests, date and time formatting, encoding/decoding, and more.
To use SwiftFoundation in your project, you can simply include the source files in your project or add it as a Swift Package.
Each extension and utility included in this library extends existing Swift types or provides new functionality to make your code more concise and expressive. Refer to the extensions listed below for details on usage.
jsonArray
sorted(keyPath:ascending:)
toggle(_:)
removeFirst(_:)
safeIndex
toDictionary(_:)
ids
mutate(_:)
init(_:)
toggle()
appVersion
buildNumber
appVersionWithBuildNumber
generateDates(inside:matching:)
urlQueryValueAllowed
isValid
isZero
string
whiteHouse
isWhiteHouse
vCard(title:)
init(placemark:)
codingKeys
unwrapJSONDataBy(key:)
applyBlockForEachJSONObject(_:)
applyBlockForJSONObject(_:)
yesterday
tomorrow
startOfDay
endOfDay
dateByAdding(days:)
noon
day
month
startOfMonth
endOfMonth
isLastDayOfMonth
setTime(from:)
daysDiff(from:)
add(_:)
add(_:to:)
add(_:)
iso8601
medium
full
mediumWithTime
monthFull
monthShort
weekday
weekdayShort
year
jsonString
percentEscaped
SecondsConvertibleComponent
seconds(in:_:)
secondsAs(_:)
dictionary
withSeparator
roundingDownWithSeparator
init(_:)
snakeCaseDecoder
decode(_:as:)
decodeIfPresent(_:)
decodeSafely(_:)
decodeSafelyIfPresent(_:)
byId(asending:)
formattedWithSeparator
roundingDownWithSeparator
capitalizingFirstLetter()
toData(using:)
evaluate(withRegex:)
id
toBase64()
fromBase64()
format(parameters:...)
sliceIncluding(from:to:)
convertHtml()
id
queryFirstValue
queryDict
init(url:method:headers:multipartFormData:)
- Provides a type-erased wrapper for Codable types.
- A property wrapper that makes a value conform to
Equatable
without actually comparing its wrapped value.
- Provides functionality to generate fake instances of types conforming to the
Faking
protocol.
- A property wrapper that makes a value conform to
Hashable
without affecting its hash value.
- A wrapper for collections that provides access to both the index and the element.
- Represents a media resource with support for generating scaled image URLs.
- A property wrapper that provides an interface for storing values in
SafetyStorage
.
- A protocol for safely saving and loading data.
This library is released under the MIT license. See LICENSE for details.