14. June 2017

Swift: Using Enums to Write Safer Code

If you have been programming for a while, especially for iOS, you’ve probably built plenty of View Controllers. The joke goes that ‘MVC’ actually stands for “Massive View Controllers”. The reason is that it is very easy to just put a lot of code inside view controllers, making them absolutely humongous.

I will not teach you how to fix that now, because that’s especially tricky, but I’m going to give you a short hint that might help you make that whole mess a lot more reliable.


20. January 2017

Swift: Coding with Options?!??

Swift utilizes a concept borrowed from type theory called “Option type”. What it means is that a variable of a certain type can be also declared to be “optional”. In other words, it may have a value set to it, or maybe not. The program will have to check this every time it tries to read the value of this variable.

“But why do you need this??” you might ask. Well, that’s a long story. So let’s get straight to it:

A little bit of history

The year was 1965. A computer scientist, Tony Hoare, was working with colleague Niklaus Wirth on designing a new programming language: Algol W. It was based on (and intended to replace) Algol 60, a successful programming language introduced in 1958 and later updated in 1960. Algol W was designed to include many advanced features such as debugging, profiling, and typed pointers (all three new concepts, and extremely innovative at the time). However, one thing was missing…


08. January 2017

MyToDo, a Basic iOS App Tutorial in Swift 3

In this tutorial we will cover the implementation of a basic iOS App in Swift that allows us to keep a to-do list.

The tutorial will cover the following areas:

  1. Setting up an iOS App project in Xcode
  2. Building a simple UI structure using Interface Builder
  3. Creating a data model
  4. Connecting the data model to the UI using a View Controller
  5. Implementing serialization to achieve local persistence

This tutorial will only use built-in features of iOS, and so we won’t use any third-party libraries. Those can be very useful, but my objective is to make this as simple as possible and without any dependencies. Even if you have never written any apps for iOS, you should be able to follow along. Also, I will assume you are interested in learning some small details regarding iOS and Swift, and will throw some trivia and explanations along the way.

So let’s get started!