Kitura Tutorial: Getting Started With Server-Side Swift | raywenderlich.com

Do you wish your iOS skills worked on the backend? This Kitura tutorial will teach you to create RESTful APIs written entirely in Swift.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1079484-kitura-tutorial-getting-started-with-server-side-swift

Awesome Tutorial!! Quick note regarding the following code snippet:

// 1 database.retrieve(acronymID) { (acronym: Acronym?, error: CouchDBError?) in guard let acronym = acronym, let acronymRev = acronym._rev else { Log.error("Error retrieving document: \(String(describing:error))") return callback(error) } // 2 database.delete(acronymID, rev: acronymRev, callback: callback) }

I think it would be nice to have a small explanation as to why you didn’t use your unwrapped acronym above. In the end, because of the guard statement, the result is the same however we could have probably omitted that variable with a _.

@dokun1 Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hey @digimarktech, thanks for the feedback!

As I wrote this, the idea was that you would have to unwrap acronym to get the ._rev property off of it on the same line. However, I suppose you could truncate this to one statement - I felt that being more verbose with this logic would be safer for the reader to understand.

I’ll keep this in mind next time :]

Thanks for the tutorial, it’s very clear and it works straight away.

I’ve never done any backend dev so I am wondering when the actual db is stored?

@dokun1 Can you please help with this when you get a chance? Thank you - much appreciated! :]

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!