What’s New in Swift 2

Check out some initial impressions of Swift 2 and some of the highlights in how we’ll be writing our apps and frameworks in the year to come. By Greg Heo.

Leave a rating/review
Save for later
Share
You are currently viewing page 2 of 2 of this article. Click here to view the first page.

Grab Bag

There were a ton of things announced throughout all the sessions, so I want to highlight a few more quick things:

  • Objective-C generics – Apple has already started annotating all their Objective-C code so that types in Swift get the correct kind of optionality. That work continues with Objective-C generics, which will give Swift developers better type hinting. If you’re expecting a set of UITouch objects or an array of strings, that’s exactly what you’ll get rather than a collection of AnyObjects.
  • Renamed syntax – println has left us after only a year; now it’s plain old print which now has a default second boolean argument set to true on whether to print a newline or not. With the do keyword focused on scope for error handling, do-while loops are now repeat-while. Similarly, there are many changes to protocol names such as Printable becoming CustomStringConvertible.
  • Migrator – With all these small syntax changes, how are you going to get your codebase up to date? The Swift 1-to-2 migrator will come to the rescue and help bring things up to the latest standards and syntax changes. The migrator is even smart enough to update your code to use the new error handling and update your docblock comments to the new style of formatting!
  • Open source! – The big news for the nerds is that Swift is going open source when Swift 2 is released in the fall. Likely this will lead to Swift being used for more than just iOS development, which makes it even more important to learn. Plus, it will be a great opportunity to get a look under the hood and even to contribute back and get your name in the Swift compiler commit history. ;]

Where To Go From Here?

This is just a sampling of the many things released; for the full details, check out the WWDC session videos and the updated Swift Programming Language book.

There will surely be more to come if anyone remembers the volume of changes between the first beta and the 1.0 release of Swift. We’ll be staying on top of all the updates here on the team, so keep an eye out for tutorials, book announcements, and videos as we dig into all the exciting changes to come.

What parts of Swift 2 are you most excited about? What would you like us to cover first? Let us know in the comments below!

Greg Heo

Contributors

Greg Heo

Author

Over 300 content creators. Join our team.