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.
jsonArraysorted(keyPath:ascending:)toggle(_:)removeFirst(_:)safeIndextoDictionary(_:)idsmutate(_:)
init(_:)toggle()
appVersionbuildNumberappVersionWithBuildNumber
generateDates(inside:matching:)
urlQueryValueAllowed
isValidisZerostringwhiteHouseisWhiteHousevCard(title:)
init(placemark:)
codingKeys
unwrapJSONDataBy(key:)applyBlockForEachJSONObject(_:)applyBlockForJSONObject(_:)
yesterdaytomorrowstartOfDayendOfDaydateByAdding(days:)noondaymonthstartOfMonthendOfMonthisLastDayOfMonthsetTime(from:)daysDiff(from:)add(_:)add(_:to:)add(_:)
iso8601mediumfullmediumWithTimemonthFullmonthShortweekdayweekdayShortyear
jsonStringpercentEscaped
SecondsConvertibleComponentseconds(in:_:)secondsAs(_:)
dictionary
withSeparatorroundingDownWithSeparator
init(_:)
snakeCaseDecoder
decode(_:as:)decodeIfPresent(_:)decodeSafely(_:)decodeSafelyIfPresent(_:)
byId(asending:)
formattedWithSeparatorroundingDownWithSeparator
capitalizingFirstLetter()toData(using:)evaluate(withRegex:)idtoBase64()fromBase64()format(parameters:...)sliceIncluding(from:to:)convertHtml()
idqueryFirstValuequeryDict
init(url:method:headers:multipartFormData:)
- Provides a type-erased wrapper for Codable types.
- A property wrapper that makes a value conform to
Equatablewithout actually comparing its wrapped value.
- Provides functionality to generate fake instances of types conforming to the
Fakingprotocol.
- A property wrapper that makes a value conform to
Hashablewithout 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.