-
-
Notifications
You must be signed in to change notification settings - Fork 115
Networking 3 Transition Guide
Hi, and welcome to the third major release of Networking. Jumping from 0.x.x to 1.0.0 was a matter of how mature the project was, before jumping to 1.0.0 the library was tested in 3 big production apps, received a lot of input from the developers and was ready to receive input from the world. Among other things, the jump to 1.0.0 brought a lot of attention, especially from iOSDevWeekly and CocoaControls.
The jump to 2.0.0 was mainly the conversion of the whole codebase to Swift 3. The jump was easy, mainly since a lot of the core APIs were left as untouched as possible to ease the jump to Swift 3, this of course meant that some parts of Networking didn't feel very swifty. After 3 months of 2.0.0 we have refined Networking, refactored the internals, improved the unit tests and now we're ready to delete all the deprecated methods and make the big jump to 3.0.0.
Things that you need to change in order to use Networking 3.
We have changed the authentication methods to be easier to understand and to increase readability.
let networking = Networking(baseURL: baseURL)
networking.authenticate(username: "user", password: "passwd")
let networking = Networking(baseURL: baseURL)
networking.authenticate(token: "hi-mom")
let networking = Networking(baseURL: baseURL)
networking.authenticate(headerValue: "hi-mom")
let networking = Networking(baseURL: baseURL)
networking.authenticate(headerKey: "Anonymous-Token", headerValue: "hi-mom")
networking.GET(...) { ...
networking.POST(...) { ..
networking.PUT(...) { ...
networking.DELETE(...) { ...
networking.get(...) { ...
networking.post(...) { ..
networking.put(...) { ...
networking.delete(...) { ...
networking.imageFromCache("/imagepath") { image in
}
networking.dataFromCache("/videopath") { data in
}
networking.cancelAllRequests {
// Finished cancelling all requests
}
networking.cancelGET("/get") {
// Finished cancelling GET "/get" requests
}
networking.cancelPOST("/post") {
// Finished cancelling GET "/post" requests
}
networking.cancelPUT("/put") {
// Finished cancelling PUT "/put" requests
}
networking.cancelDELETE("/delete") {
// Finished cancelling DELETE "/delete" requests
}
let image = networking.imageFromCache()
let data = networking.dataFromCache("/videopath")
networking.cancelAllRequests()
networking.cancelGET("/get")
networking.cancelPOST("/post")
networking.cancelPUT("/put")
networking.cancelDELETE("/delete")