A light weight Swift Package for making web calls.
Callable was created to solve the tiresome and tedius chore of writing URLSession.shared.dataTask
etc. etc. etc.
Copy the .git
url for this repo.
Paste it here:
Click enter, then follow the prompts.
Add this project on your Package.swift
import PackageDescription
let package = Package(
dependencies: [
.Package(url: "https://github.com/ElevatedUnderdogs/Callable.git", majorVersion: 0, minor: 0)
]
)
You can simply specify your URL
and then access either Data
, JSON
or through the magic of generics: a Codable
type.
import Callable
URL(string: "http://api/website.com").callCodable { (myStruct: MyStruct?) in
print("The data", (myStruct == nil ? "doesn't convert": "converts"), "to MyStruct.")
}
URLRequest
conforms to Callable
as well, so you can do the same thing:
import Callable
let myURLRequest: URLRequest!
myURLRequest.callCodable { (myStruct: MyStruct?) in
print("The data", (myStruct == nil ? "doesn't convert": "converts"), "to MyStruct.")
}
Scott Lydon – Linkedin
Distributed under the MIT license. See LICENSE
for more information.
link |
Stars: 0 |
Last commit: 43 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics