Thoughts on iOS 5

Now that WWDC is a fading memory (when will those videos of the sessions show up for those of us who could not go…) I wanted to comment on the two things I am most excited about with iOS 5. Of course everything is under NDA so my comments are limited to what was in the keynote or has otherwise been made public by Apple.

iCloud

A lot of details about iCloud were revealed in the keynote but I am interested in what it might mean for iOS developers.

Consider the case where I have a reading application or a game where I already save things like bookmarks or game progress to a local plist file on the device. If I have the same app installed on both my iPhone and my iPad I have no way to have the app stay in sync between those two devices. The same applies if I have an app that creates content, currently the only way to make that content turn up on all devices is to use the cumbersome mechanism provided by iTunes or an external service such as dropbox.

There are a great many iOS apps which are effectively stand-alone apps that fit this model. Since the apps do not need to connect to a central server there is no requirement for the app developer to deploy and run a hosted server which costs real money. However the downside is that each instance of the app running on a particular device is completely ignorant of other iOS devices the user may have.

For apps that already rely on a web service or some other hosted server I suspect iCloud will not make much difference but for all other apps I expect it to have significant impact. In fact I would expect all iOS apps to allow for basic settings and preference information to be sync’ed between all iOS devices the user has. This means that if I have been using an app on my iPhone and then decide to also install it on my iPad that the app starts up on the iPad with exactly the same settings and app context that it has on the iPhone and that the two devices stay in sync.

If you are looking at moving you apps to iOS 5 (and why would you not) then I think building in a basic level of iCloud support for settings and app state should be one of the first things you target.

Automatic Reference Counting (ARC)

This announcement, tucked away on a single keynote slide, during the WWDC keynote was really totally unexpected. Objective-C 2.0 has language support for garbage collection but it can only be used with Cocoa apps running on OS X. For iOS we have been stuck with performing our own memory management using retain, release and autorelease. Once you get the hang of the Objective-C conventions I do not find managing the retain/release cycle to be that hard but it remains a big hurdle for new iOS developers to jump over and a source of memory leaks and app crashing bugs.

I had long assumed that as iOS devices get more powerful we would eventually arrive at a point where Apple would also support garbage collection on iOS unifying the two Cocoa platforms. I was not expecting that to happen this year but I was guessing or hoping it would be coming soon. Apple though would not be Apple if they could not occasionally pull a rabbit out of the hat and do something unexpected.

You can find a lot of detail on ARC on the LLVM compiler site - see Automatic Reference Counting. Be warned that it is not easy reading and you may want to wait until the WWDC session videos are available. In brief, and again staying on the right side of the NDA, it is a compiler feature that promises to automatically take care of the retaining/releasing of objects for us. The promise for an iOS developer is that you will not need to worry about retaining and releasing objects manually. The LLVM compiler is now smart enough to manage the objects for you and automatically insert the retains/release methods for you at compile time.

If you have used the Clang language analyser you will have already seen how smart the LLVM parser has become. It is already capable of highlighting errors with retain and release so I guess it was the logical next step to just let the compiler insert the correct memory management methods into the code for us.

When Objective-C 2.0 came along and introduced properties with the dot syntax it created some controversy for long time Objective-C programmers who felt it hid what was happening under the covers and could be misused. I guess the same will be true with ARC with many experienced developers preferring to stay with manual memory management. It is too early to pass judgement but in theory if ARC lives up to its promise it could both simplify and speed up iOS apps without the need to implement garbage collection which as Steve would say is magical.