Up to date documentation can be found at: SchafKit Wiki
A kit providing useful functions across iOS, watchOS, macOS and tvOS, taking advantage of Swifts rich feature set.
SKCryptography
is a wrapper around TweetNacl, providing the Curve25519XSalsa20Poly1305BoxAlgorithm
, XSalsa20Poly1305SecretBoxAlgorithm
and Ed25519Algorithm
classes.
SKDispatchHelper
helps submitting blocks to dispatch queues.
SKDispatchHelper.dispatch(
on: .main,
block: {
// Do something here
})
SKFileSystemItem
and its subclasses SKFile
and SKDirectory
provide easy access to the File System.
Networking offers an easy way to send simple or advanced network requests. The examples below use Swift 5.5's await
. Everything is also possible to use with a callback.
Simple:
do {
let result = try await SKNetworking.request(
url: "https://github.com/Quintschaf/SchafKit"
)
print(result.stringValue) // Prints the html received
}
Advanced:
let block : SKNetworking.RequestCompletionBlock = { (result, error) -> Void in
// Do something here, for example: result.jsonValue?["Test"]["Toast"]
}
let headerFields : [SKNetworking.Request.HeaderField: String] = [
.accept : "*/*",
"CustomField" : "CustomValue"
]
let result = SKNetworking.request(
url: "https://github.com/JannThomas/OpenKit",
options: [
.requestMethod(value: .post),
.headerFields(value: headerFields),
.body(value: .xWwwFormUrlencoded(value: ["Key" : "Value"]))
]
)
// Do something with the result
SKRegexMatch
handles regular expressions.
guard let matches = "Test".regexMatches(with: "(T)est") else {
return
}
print(matches.first?.captureGroups.first) // "T"
A big part of SchafKit
are extensions. You can find all of them in the documentation, but here are the most important ones with examples.
Variable | Return Type | Description | Result |
---|---|---|---|
empty | String | An empty string. | "" |
space | String | A string containing a space character. | " " |
newline | String | A string containing a newline character. | "\n" |
tab | String | A string containing a tab character. | "\t" |
Variable | Return Type | Description | Example | Result |
---|---|---|---|---|
localized | String | A localized version of the receiver. | "DONE_BUTTON_TEXT".localized |
"Done" |
urlEncoded | String | A URL-encoded version of the receiver. | "https://quintschaf.com".urlEncoded |
"https%3A%2F%2Fquintschaf.com" |
urlDecoded | String | A URL-decoded version of the receiver. | "https%3A%2F%2Fquintschaf.com".urlDecoded |
"https://quintschaf.com" |
extractedSeconds | Int? | Extracts number of seconds from the receiver in a hh:mm:ss/mm:ss/ss format. | "00:02:15".extractedSeconds |
135 |
SchafKit also includes sane subscripts for Strings, making syntax like "abc"[0...1]
possible.
SchafKit relies on Swift Package Manager and is installed by adding it as a dependency.
We have chosen to use the CC0 1.0 Universal license for SchafKit. The following short explanation has no legal implication whatsoever and does not override the license in any way: CC0 1.0 Universal license gives you the right to use or modify all of SchafKits code in any (commercial or non-commercial) product without mentioning, licensing or other headaches of any kind.
- Implement SKFile
- Uploading in Networking
- More Extension Examples in README
- Full Documentation
-
SKAlerting
-
SKStoreKitHelper
-
SKJsonRepresentable
- Custom SwiftUI components
-