Skip to main content


Writing unit testing is a cornerstone of software development.  When developing mobile or desktop applications, unit testing becomes even more critical, as there is often vital business logic that needs to be validated.  Have you ever found yourself wondering; what makes a great unit test in Swift? What key components give my application enough testing coverage to make sure that everything works and nothing regresses when new code is added to my project?  If you have asked yourself these questions then you are not alone.  In fact, that is why I wanted to write this tutorial.

In the last couple of months I have found myself in situations where I have needed to diagnose transport security issues from from the context of an iOS application.  This often can be difficult from the client side perspective as you may not know anything about the minimum TLS version, preferred cipher suite, or the certificate in use on the server.  Often, the best move you have, if you do not have a direct line to the server side team, is to test different settings to diagnose what works and what does not.

So there you are, you just finished the last lines of code needed to complete a ticket on one of the big features of your application.  Now what?  Submit a pull request and have your team review it?

If you are like me and have ever found yourself wondering, "what is the exact syntax on how completion handlers are setup in closures?" Then this tutorial is for you.  I wrote this tutorial with the idea in mind that sometimes it is nice to have a resource to reference when writing and defining completion handlers in your Swift project.  I also wanted to provide a quick reference on how to setup a completion handler as a function and as declared constant.  So all you have to do is make the decision about what makes the most sense in your project.


Have you ever found yourself trying to remember the syntax on how to grab the first few characters from the start or end a string in Swift 4.  Well, I certainly have from time to time and that is why I wanted to write this tutorial. To show you the reader how to grab the first few characters from the start or the end of a Swift string using only two Swift Standard library methods, and from there show one more slightly advanced technique.  So by the end of this tutorial you should be able to get the first few characters from the start or the end of a string in either Swift 3 or 4.