viewDidLoad, viewDidUnload, AND supporting previous versions


#1

I read elsewhere in these forums (search viewDidUnload) and the blog (thejoeconwayblog.wordpress.com/) about how views are no longer unloaded and thus code related to viewDidUnload in the book can be ignored. However, perhaps because I’m new to iOS, I have the following questions.

  1. Is it unreasonable for code to be written to support multiple iOS versions? I would think that there are a lot of device with iOS5 (or earlier?) that can’t or won’t update to 6.
  2. Assuming it’s not unreasonable, should we leave all the “viewDidUnload” and support for weak references mentioned in Chapter 7 in the code? Or perhaps put in some sort of switch (if version 6 do this, else {})?
  3. How do we set the simulator to test iOS5 (or earlier). When I look at the Hardware menu for the simulator, I see version, but the only choice is 6.

Thanks,
Dave


#2
  1. Typically, people back support one major revision if they have the funds/time. (I advocate for only supporting the current version, since by the time you ship, that will be the previous major version.) Devices typically support a few into the future, so unless you are really concerned about supporting something with a 4 year old iPhone (who probably doesn’t buy many apps), you are good just supporting the current version and the last.

  2. Later on, you will see how weak references take care of the view hierarchy. You probably won’t have to implement viewDidUnload even in iOS 5 apps. If you support back to 4, yes. If you support back to 3, you don’t even get viewDidUnload IIRC.

  3. You can download old simulator versions from the Downloads tab in the Preferences pane.