title: What to watch out for when transitioning to iOS 5
body: <p><strong>Summary:</strong> <em>Can you add to my checklist of things to watch out for when migrating to iOS 5?</em>  StackOverflow has been invaluable as I've worked on upgrading to iOS 5.  I've discovered some pretty basic things I'd missed prior to Xcode 4.2, and I'm wondering what other "gotchas" might be lurking.</p>
  
  <p><strong>Detail:</strong> With iOS 5 shipping this week, I've had to make some changes to a couple of my apps.  Xcode 4.2 does a much better job analyzing memory management code because of the new ARC feature.  The iOS 5 update is a great point at which to review all your memory management code.  The new compiler also finds a number of other issues that earlier compilers missed.  Kudos to the Apple compiler engineers.  Here are the main things that have helped (and many of them will also apply to earlier versions of iOS).</p>
  
  <ol>
  <li>Make sure to <a href="https://stackoverflow.com/questions/4566453/correct-super-dealloc/4566488#4566488">call [super dealloc] at the END of your dealloc methods</a>, not the beginning.</li>
  <li>In viewDidUnload, <a href="https://stackoverflow.com/questions/2365440/iphone-super-viewdidunload-calling-order/5503408#5503408">some people have reported bugs that require [super viewDidUnload] to be called at the end</a>, not the beginning, of your viewDidUnload.</li>
  <li>Understand retain counts, synthesized setters, and when to call release or autorelease.  The new compiler will point out more problems than the older compilers did.  (I thought I'd been careful, but apparently I wasn't careful enough.)  Apple's <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html#//apple_ref/doc/uid/20000994-BAJHFBGH" rel="nofollow noreferrer">memory management guide</a> is required reading -- no shortcuts.</li>
  <li>It's a good idea to <a href="https://stackoverflow.com/questions/4168327/what-is-nszombie/4168365#4168365">turn on zombies when debugging</a> (in Xcode, choose Product | Edit Scheme... and select the Debug scheme; on the Diagnostics tab, check Enable Zombie Objects).  This can help you find attempted uses of zombies (objects you shouldn't be using any more).</li>
  <li>The Leaks instrument is also helpful.  Run your app in Profile mode and choose the Leaks template.  In the Instruments window, select the Leaks instrument and check the box that says "Gather Leaked Memory Contents" and it will help you see where the leaked memory originates in your code.</li>
  </ol>
  
  <p>There are a few odds and ends I've encountered:</p>
  
  <ul>
  <li>Apple's <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW32" rel="nofollow noreferrer">singleton pattern</a> needs "oneway" added to the return type declaration:</li>
  </ul>
  
  <pre>
      - (<b>oneway</b> void) release { }
  </pre>
  
  <ul>
  <li>You may need to <a href="https://stackoverflow.com/questions/7053466/application-executable-is-missing-a-required-architecture-armv6/7667814#7667814">manually add "armv6" as an architecture type</a> in your Build Settings (and be sure Build Active Architecture Only is set to NO).</li>
  </ul>
  
  <p>Any other suggestions of potential pitfalls I should look for?  I have a feeling that my apps are more stable now, but I felt pretty good about them before.</p>