Compiled Chronicles

A software development blog by Angelo Villegas

Category: Swift

  • Swift: Concurrency

    The async/await feature has been added as part of the newer, more structured take of Swift with concurrency and was released with Swift 5.5 during WWDC 2021.^1 Concurrency is the ability to execute multiple computations asynchronously. Swift added two keywords: marking asynchronous functions with async, then calling them using await. Problems and Motivations Before the addition of async/await, asynchronous programming was achieved with completion handlers. Completion…

  • Swift: Phantom Types

    Playing around Swift for some time and you might have encountered a bug or errors on your code by summing up or multiplying variables with different types. Well, not really just Swift but a lot of programming languages have the possibility to calculate variables of different types resulting to possible bugs and/or errors. Phantom Types try to…

  • Swift 2.0

    With the WWDC 2015 came many improvements with Swift — not just making writing code much more beautiful, but also better error handling, and new optimisations that will make your app run even faster. Back to Basics So Swift 2.0 is here with a lot of new features. If you already completed the Swift programming ebook that Apple released last year, then reading it…

  • Swift: JSON Parsing

    JavaScript Object Notation. JSON, pronounced (/ˈdʒeɪsən/ jay-sən), is an easy standard to parse in client-server application data. It is easy to implement and simple to understand. With the release of iOS 5 back in 2011, the NSJSONSerialization class was added in the SDK, which gives an easy to use delegate method to parse JSON data. What is JSON? JSON is a text-based, lightweight and easy…

  • Swift: Protocols

    In Objective-C, you are allowed to define protocols which declare the methods expected to be used for a particular situation. In t, protocols are basically a named contract that your types should conform to. If your type says it conforms to Equatable, then it better fulfil all of the required methods to make it equatable. Protocol A protocol defines the body of methods, properties, and other requirements…

  • Swift: Operator Declaration

    The Swift standard library defines a number of operators, many of which are available to most programming languages. The most familiar operators that will come to mind are the MDAS operators’ *, /, +, – respectively. Operators such as these are very simple to use and remember that it was thought ever since we were kids. But not all operators are easy to remember, not all…

  • Swift: Range Operators

    Swift includes two range operators, closed range and half-closed range, which are shortcuts for expressing a range of values. Range operators are most commonly used with the for loop. In Objective-C, we have 2 different for loops, the traditional loop and iteration-based loop. Traditional For Loop The traditional for loop found in C requires 3 parts: the initialisation, the condition, and the loop expression. The initialisation declares (and perhaps…