Swift 2.2 Changes

Like everybody else, I spent a few hours this week updating my personal projects to Swift 2.2 which was released with Xcode 7.3 a few days ago. Updating to Swift 2.2 was important in my case since 2.2 version is basically an intermediate release between Swift 2.0 and the upcoming 3.0 version. This prompted me to take a few moments and write about the changes I had to implement in my code. There is a nice write up about the changes on www.swift.org if you are interested in more details.

Let’s begin with simple things.

The above operators are deprecated. If you try using them in Swift 2.2, you will get a compiler deprecation warning. These operators will be removed in Swift 3.0. The solution is to use the syntax which looks like this:

Traditional, C loops are also deprecated in favor of Swifts, new way.

Using literal strings as selectors was also deprecated in Swift 2.2 in favor of a much better, compiler enforced way to specify selectors. We also get autocompletion!

We can now easily compare tuples thanks to Kevin Ballard.

The last thing I want to mention is the ability to check Swift version. Quite honestly I am not sure if this is something I will use in my production code… I tend to update my code to the latest Swift version as soon as possible as it allows me to learn “new stuff”.

There are other interesting things worth mentioning about Swift 2.2:

Allow (most) keywords as argument labels
Constraining AnySequence.init
Replace typealias keyword with associatedtype for associated type declarations

Swift 3.0 is on the horizon. Get ready.

Swift 2.2 Changes

One thought on “Swift 2.2 Changes

Leave a Reply

Your email address will not be published. Required fields are marked *