iOS Development – Targeting iOS 5 and ARC vs Earlier Versions with MRC

iosiphoneobjective c

I personally don't know much about iOS 5, but it seems like with automatic reference counting (ARC), you get rid of much of the memory management issues of the previous operating systems.

So is it better to target iOS5 (and create apps that can only run on the newest iOS devices), or is it better for her to target iOS 4 or even iOS 3, so she understands the fundamentals of memory management in Objective-C? Are there any important aspects of iOS development that she might miss out on by jumping into iOS 5?

Best Answer

Worrying about memory management

ARC is a godsend: it doesn't solve every problem, but it's much better than having to do it all yourself or the short detour into garbage collection with Mac OS X.

There are two things to keep in mind with it:

  • it's a compiler feature: Xcode provides ARC support for building to iOS 4 targets1.
  • It's optional, even targeting iOS 5. If you want to learn manual reference counting (MRC) just to make extra sure you know it, you can do it even targeting iOS 5.

But ARC doesn't take away the ability to understand how memory management works, it just removes the tedium of having to declare release and retain everywhere. Justin on Stack Overflow gave a good summary of the difference between ARC and manual reference counting (MRC):

If you don't want to learn MRC, then you may want to first try ARC. A lot of people struggle with, or try to ignore common practices of MRC (example: I've introduced a number of objc devs to the static analyzer). If you want to avoid those issues, ARC will allow you to postpone your understanding; you cannot write nontrivial objc programs without understanding reference counting and object lifetimes and relationships, whether MRC, ARC, or GC. ARC and GC simply remove the implementation from your sources and do the right thing in most cases. With ARC and GC, you will still need to give some guidance.

Beyond whether or not you should use ARC, you ought to consider support for the OS version: does it really make sense to focus on version-specific features (like zeroing weak references) when there aren't a whole lot of people using that version?

Or worse yet, if everyone's using iOS 3, how long do you have to wait until you can even start to use ARC?

This comes down to two things: device support and market share.

Device support

Thankfully, one of the benefits to developers with respect to iOS development is that the latest version of the software runs on older devices; generally going back at least 2 years.

So if you want to target iOS 5, you'll be able to target the following devices:

  • iPhone 4S (released October 2011)
  • iPad 2 (released March 2011)
  • iPod touch (4th generation, released September 2009)
  • iPhone 4 (released June 2010)
  • iPad (released April 2010)
  • iPod touch (3rd generation, released September 2009)
  • iPhone 3G S (released June 2009)

Which is a large set of options. If you target iOS 4.2, you can hit every device since iPhone 3G was released back in June 2008.

Market share

Which comes to the other question: should one spend time learning anything other than iOS 5 SDK: it depends on what you want to do.

If you want to just focus on the latest and greatest, use all the neat features available in the latest SDK, and damn market share (for now): by all means go for it.

If you want to maximize market share now, I'd hold off for a few more months.

Marco Arment, the creator of Instapaper (a really popular iOS app), publishes his usage stats from time to time and just released the latest report a few days ago. In it, he notes that iOS 5 has a 45.1/48% iPad/iPhone market share, while iOS 4.2 (needed for CDMA iPhone 4s that haven't upgraded to iOS 5 yet) has a 97/97.2% market share.

Generally, hitting 97% of the potential market is "close enough": I've seen it as a rule of thumb not just for iOS development, but for web development as well.

But one thing to consider is how long of a development cycle you're going to have. If you're not planning on launching for a few months, iOS 5 is not a bad choice, even if you're trying to hit a large portion of the potential market share.

iOS users tend to upgrade much quicker than on other platforms, for a variety of reasons, and there's no reason to believe the upgrade from iOS 4.x to iOS 5 will trend any differently. If you take iOS 4.2's market share as a baseline, it was only released a year ago. It's not unreasonable to assume that October of next year iOS 5 will be well into the 90% range.

Conclusion

Don't worry about memory management too much: ARC is a great convenience, but it's not a huge paradigm shift from earlier versions. Instead, worry about the other features and support issues. If you're launching today and need to hit the largest market share possible, target iOS 4 and consider using MRC. Otherwise, target iOS 5 and consider using ARC.

1caveat: you lose out on some features if you need to target < iOS 5, like zeroing weak references. If you want to go whole-hog into ARC, you're probably better off targeting iOS 5.

Related Topic