I'm starting to write the second version of our iPhone app and I'm trying to tidy up previous mistakes (as it's my first attempt at Objective-C). My question is related to "things I need to do when a UIViewController is destroyed", there seem to be a few contradictory answers out there and I want to make sure I understand correctly.
Couple of constraints:
- This code is for use with iOS 5 and iOS 6 devices
- I don't wish to register and deregister NSNotifications on viewWillAppear and viewWillDisappear because the UIViewControllers need to receive notifications even if they can't be seen by the user.
- I'm using a StoryBoard rather than separate nib files.
So considering the above constraints, are the following statements true?
- IBOutlets connecting the storyboard to the UIViewControllers should be weak, the strong reference will be created behind the scenes.
- Because the IBOutlets are weak I shouldn't need to nil them out in low memory situations
- I shouldn't use viewDidUnload because it's being deprecated instead I should use didReceiveMemoryWarning. In this situation I only need to nil out strong properties (that can re-calculated)
- It's acceptable to register for NSNotifications on viewDidLoad.
- Because I wish to continue receiving notifications when the view is hidden, the best place to unregister them is in dealloc, there's no benefit in also unregistering them in didReceiveMemoryWarning.
Thanks for your help,
Dan