Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Changes from iOS 5 to iOS 6

We're in the final stages of completing the iOS 6 edition of the book right now, and I thought I'd take a moment to talk in general about the changes that we've seen in the iOS 6 SDK that have had the biggest impact on the book in terms of changes.

We've made lots of adjustments and improvements throughout the book, but there are a lot of recurring issues that fall into a few general categories which are worth mentioning. If you're using the iOS 5 edition of the book with the iOS 6 SDK, hopefully these points will help you sort out some common problems.

Removal of the viewDidUnload method

This UIViewController method is deprecated in iOS 6, and is no longer called. Most of the time, this change affects nothing in our projects, but I think there are a handful where we moved some code into a viewDidDisappear: or viewWillDisappear: method instead.

Restructuring of Xcode's "new file" assistant

Apple has removed some of the options there for creating a particular kind of subclass through an icon of its own. Instead, you just create a new Objective-C class and choose the appropriate superclass, and Xcode generates the appropriate template. For example, in the past there was an icon in the assistance specifically for creating a UIViewController subclass. Now, you instead just create an Objective-C class and choose UIViewController (or one of its subclasses) as your superclass.

File template changes

Apple changes its templates for various classes and projects now and then, and a huge part of our book-refresh process is going through all our examples and making sure that we're describing the current reality. Sometimes this means that Apple has removed an otherwise empty method implementation, so when we talk about adding some code to an empty method that now isn't there, you just need to add that method.

Automatic property synthesis

In the past, any @property declaration in an @interface had to be matched by something explicit in the @implementation block. Most of the time we would have a simple @synthesize to match, and occasionally we implement getters and setters in code. Starting in Xcode 4.4 and 4.5, there's another option: You can just leave out the @synthesize entirely, and the compiler will create the getter and setter for you. At the same time, it will create an instance variable. The trick is that the new instance variable doesn't have the same name as the property; instead, it's the property name prepended with an underscore. So a property named "foo" is now backed by an instance variable named "_foo".

The @synthesize syntax has always allowed you to specify the name of the instance variable. In effect, the new behavior is that when implementing the implementation for a property "foo", just skipping the @synthesize call is the same as doing this:

@synthesize foo = _foo;

This new approach lets you create your classes with less repetition, and it's really a welcome change. Throughout the book, we've adopted this approach, and have removed @synthesize pretty much everywhere.


The old "springs and struts" method of specifying how the layout of views should respond to changes in the size of a parent view has been replaced by a new system called Cocoa Auto Layout, which has been on the Mac for just over a year and has now made its way to iOS. Auto layout is a constraints-based system that can do everything that the old system could do, and a whole lot more. Most of the time, you can build your GUIs just the same as before and things will work pretty much as expected, with one serious caveat: the iPhone 5 throws a monkey wrench into the works. Before the iPhone 5, iOS developers could assume that the iPhone screen size was a known quantity (with the obvious exception of iPad, which is often solved by using different nibs/storyboards entirely), and could often assume there was no need to worry about GUI autosizing for an iPhone GUI, particularly if you disallowed rotation. Now however, the GUI you create in Interface Builder may well be loaded up on an iPhone whose screen size is taller or shorter than what you've built for. Depending on how the constraints in your GUI are configured, you may have some weird things happening in your GUI.

This is obviously something that is as new to us as to anyone else, since we had no confirmed info about the iPhone 5 until it was publicly revealed. On our final pass through the new book, we are taking extra care to look at our examples and see which need adjusting. It's hard to give concise, general advice about this, but if you're interested in this topic, you should take a look at Apple's Cocoa Auto Layout guide for starters.

I hope this helps! Let me know if you have any questions about any of this.



  • The book keeps saying 'save the nib and run', or similar, but when I forget to save it seems to be OK.

    I'm assuming that this is because it's now all one large application rather than a separate interface builder, but am I storing up grief for later?
  • No worries! Xcode nowadays automatically saves all unsaved files as soon as you click "build". In the old days it wasn't so, especially not where nib files were concerned, so the book was written with that in mind. At some point we should perhaps focus on trimming such things away. Maybe next time!
  • I'm working through Chap 7 of your book for iOS5 using Xcode 4.3.1. So I should be OK using the iOS 5 book on Xcode running iOS 5.  However, after getting the slot machine view to work just fine, I added the final details of adding sound. I've checked my typing three times now, so I don't think I've made any mistakes, and now my build is failing with three errors saying something about undefined symbols for architecture i386:

    "Undefined symbols for architecture i386:
      "_AudioServicesCreateSystemSoundID", referenced from:
          -[BIDCustomPickerViewController playWinSound] in BIDCustomPickerViewController.o
          -[BIDCustomPickerViewController spin] in BIDCustomPickerViewController.o
      "_AudioServicesPlaySystemSound", referenced from:
          -[BIDCustomPickerViewController playWinSound] in BIDCustomPickerViewController.o
          -[BIDCustomPickerViewController spin] in BIDCustomPickerViewController.o
    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)"

    Any idea what's going on here? Also, is there an errata file or forum for the iOS 5 book?
  • My mistake. :-(  I just read page 214!  :-)
Sign In or Register to comment.