Swift Nil Coalescing – Intermediate

How many times have you done some simple logic along these lines?

Well why not keep the code simple and stop your developer friends from teasing you by making these more efficient and impressive looking by using the Nil Coalescing Operator. You can represent the above with the simpler code below

Read Full Article…Swift Nil Coalescing – Intermediate

Swift Enumerations – Intermediate

What is a Swift enumeration? Well to quote the official documentation

An enumeration defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code.

OK, so seriously, what is an enumeration?

Well it turns out that the documentation is pretty accurate but makes them sound more complicated than they really are (because programmers like to do that), the easiest way to learn what they are is to just play with them. Let’s open a new Swift playground and start playing.

Read Full Article…Swift Enumerations – Intermediate

Dictionaries in Swift – The Basics

Dictionaries in Swift can be a very powerful asset when managing data. For those of you coming from other languages you may already of encountered them by a different name associate arrays.

At the heart of a dictionary is a very simple concept, each item in the dictionary is a pair, however unlike an array the can be any kind of object, BUT all the keys MUST be the same kind of object, this also applies to the values. Keys and values do not have to be the same type though which can be handy.

So with the basic rules out of the way here is an example of creating a Dictionary.

Read Full Article…Dictionaries in Swift – The Basics