WWDC 2015 Initial Impressions
Check out my first impressions as an iOS developer on the new changes in Swift, watchOS, iOS 9, and more! By Ray Wenderlich.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
WWDC 2015 Initial Impressions
10 mins
I wasn’t lucky enough to get a WWDC ticket this year, but I’m still in San Francisco so I can hang out with fellow iOS developers and attend AltConf.
I’ve been having a great time so far, following and discussing all the exciting news with everyone here!
Although I haven’t had time to go through all the docs and samples yet, I thought it might be useful to post some of my initial impressions of the goodies in store for us this year.
Feel free to post any of your own thoughts, or anything I may have missed!
Swift Updates
The most exciting change for me was something that affects all Swift developers – the release of Swift 2.0, and that Apple will be making Swift open source later this year!
Greg will be posting a detailed roundup of what’s new in Swift 2.0 in a few days, but here’s three changes that especially stood out for me:
1) Error Handling
There’s an entirely new way to handle methods that return errors. The days of NSError
are gone; there’s now a new system that looks somewhat similar to exception handling. One of the advantages of this system is that it makes it harder to accidentally ignore errors in your code.
Here’s a quick example that shows how this works:
let beers = 2
let sessions = 2
let hoursOfSleep = 4
enum WWDCAttendeeError: ErrorType {
case TooExcited
case TooTired
case TooDrunk
}
func attendSession() throws {
guard sessions < 3 else {
throw WWDCAttendeeError.TooExcited
}
guard hoursOfSleep > 2 else {
throw WWDCAttendeeError.TooTired
}
guard beers < 3 else {
throw WWDCAttendeeError.TooDrunk
}
print("Great session!")
}
do {
try attendSession()
} catch WWDCAttendeeError.TooExcited {
print("Too excited!")
} catch WWDCAttendeeError.TooTired {
print("Too tired!")
} catch WWDCAttendeeError.TooDrunk {
print("Too drunk!")
}
I consider myself as exhibiting all three of these errors right now ;]
We'll go into more details about this in future articles, but I definitely consider this one of the biggest changes to Swift, and something we'll all need to get used to.
2) Protocol Extensions
With protocol extensions, you can actually add new method and property implementations to any class that implements a protocol. For example, this would add a new method knockKnock()
to any class that implements Equatable
, such as Int
:
extension Equatable {
func knockKnock() -> String {
return "Who's there?"
}
}
let a = 1
print(a.knockKnock())
With protocol extensions you can also add default implementations of methods to protocols too. I think this will turn out to be handy!
3) Labels
Just when you thought the days of GOTO
were gone... labels return! ;]
Labels provide a way for you to break execution of an inner loop out to a higher level condition or loop, for instance:
outer: for i in 1...10 {
for j in 1...20 {
print("\(i), \(j)")
if j == 5 {
break outer
}
}
}
This will only print out (1, 1) to (1, 5), and then terminate. There have been a few cases where I could see this making code a bit cleaner.
And More...
There are a bunch of other changes too - stay tuned for Greg's article for more details!
WatchKit Updates
Apple Watch developers around the world rejoice - we can now write native apps for watchOS 2!
When I first heard this, I was worried that it would make everything we've learned with WatchKit obsolete. However, according to what I can tell from the watchOS 2 Transition Guide, this is actually not the case.
Instead, it seems like you still make WatchKit apps the same way - you still create WKInterfaceControllers
, you still use the same kind of controls and layout system - but now the code now runs on the watch, instead of on your phone.
This has a number of repercussions:
- Better performance: Since code is running natively on the watch your apps should perform better. I haven't tested this yet though - if anyone has let me know your findings!
- More device access: You now have programmatic access to the digital crown, microphone on the device, health sensor data, accelerometer, and more - these will enable new kinds of apps.
- New connectivity: Now that your WatchKit app is running on the watch itself, you can no longer use shared container for files - if you want to share files, you either need to use the new Watch Connectivity framework, or re-architect your code to have both the iPhone app and watch pull data over the network from a shared server.
Mic Pringle will be writing an article with more details on these changes. And before anyone asks - yes, we are planning a second edition of WatchKit by Tutorials! :]
iOS 9 Updates
There were a number of important changes in iOS 9 this year - not as many as previous years, but still a bunch of things you'll want to be aware of. Here are my top three:
1) Multitasking Enhancements on iPad
One of the first things Apple demonstrated in the Keynote was that you can now run two apps at once on iPad, side-by-side in a split view.
If your app is using Auto Layout and Adaptive Layout correctly, for the most part this should just work. It basically means that sometimes your view controllers may have compact width size class on iPad, such as when it's displayed on the right hand side of the split view. Also, if the split view is extended to 50% then both sides are compact width.
There are a few edge cases to keep in mind though, covered in the Slide Over and Split View Quick Start guide.
2) Search APIs
Another pretty cool new feature is that you can now make activities and documents within your app searchable by Spotlight using some new APIs.
You can also make special links on your site that when tapped by a user (and they have your app installed) will launch your app at a specific view in your UI flow, similar to Facebook's App Links.
I expect we'll see a lot of developers wanting to take advantage of this.
3) Other Cool Changes
I ran a quick poll on Twitter to see what else folks were the most excited about, and here's some of the top winners:
- Testing Improvements: Rather than write your UI testing in Javascript, Xcode now has a feature that allows you to record your interactions with your app and automatically generate the test code for you! It also has a nice code coverage feature that will highlight the parts of your code that are covered by unit tests.
- CloudKit JS Library: One common complaint about CloudKit was that if you used it, you couldn't make a web app that accessed the same data. That is no longer the case with the new CloudKit JS library!
- App Thinning: Apps have become bloated over the years with @1x, @2x, and now even @3x images, multiple binaries, and so on. App Thinning makes it so only the files that are needed to run on the device are included - and most of this happens automatically. There is also a new system that allows you to store some of your apps resources on the App Store and download them on demand to further reduce binary size - see the On Demand Resources Guide.
- Contacts/ContactsUI: The ancient AddressBook API has finally been rewritten in an Object-Oriented fashion. Hip hip hooray!