views:

91

answers:

1

App has 4 view controllers; Menu, A, B and C, and a singleton class to hold data in 4 arrays that are written to disk at app termination. A selection from the Menu creates an instance of A, "a"; a selection from "a" creates an instance of B, "b", and from "b", a selection bring up a modal data entry view "c".

I simulate a memory warning from "b" and the contents of the 4 arrays (entered in "c") disappear, but not immediately, only after going back to "b" (still exists in "b") then back to "a" - somewhere in "a" between the viewDiDAppear, where the data displays perfectly and viewWillDisappear, where it's gone, even when the only thing I do is hit the back button.

In my experience, memory warning release views but I am puzzled why arrays appear to be released. I tried 'retain' after creation but the contents still disappear.

Any thoughts on what might possibly be happening are appreciated.

Thanks.

A: 

What wasn't totally obvious to me (although it should have been), was that when views are released, the next time that view is called for, the viewDidLoad method is again called; since I initialized my arrays in a viewDidLoad method, they were being wiped out.

Hope one day in the future this post saves someone the time that I wasted on this (and at least then I won't feel so bad that about the 'duh, view gone, viewDidLoad has to be called')

Matt Winters