Category Archives for Swift

Swift: Access Control

Encapsulation is one of the most important object-oriented design principles: It hides the internal states and functionality of objects.  You can achieve this by using the access control features of

Continue reading

Swift: Enums

An enum is a data type that has a finite set of possible values. In this post we discuss the most important aspects of enums in Swift. Declaration The declaration of an enum is very straightforward in

Continue reading

Optionals in Swift

In Swift every variable can be declared as a so-called optional – then the variable is allowed to become nil what is equivalent to the absence of a value. In this post we will discuss the most

Continue reading

Error Handling in Swift 2.0

Swift 2.0 has a new way of error handling. It uses a do-try-catch  syntax,  which is the replacement for NSError .  In this post we will discuss how to use this new syntax.

Continue reading

Singletons in Swift

Some people love it, some people hate it – but in the end everybody uses it: the singleton pattern. It is used if just one instance of an object is desired. For example, that could be a database

Continue reading

One Year of Swift

One year ago Apple introduced Swift, which was a very surprising move.  What remains after one year?

Continue reading

Swift 2.0: defer

defer is another new keyword in Swift. With this statement you can declare clean-up code, that is executed just before the current scope ends. For example, this scope can be a function or a loo...

Continue reading

Swift 2: guard

In Swift 2, there is a new keyword for handling the control-flow of a block of code. It guarantees, that a specific condition holds true for the further code. Otherwise, it ensures that the following

Continue reading

Properties in Swift

Properties are a very interesting feature in Swift, which makes the usage of properties much more natural than in Objective-C. There are two types of properties: Stored properties and computed properties.

Continue reading