Simulate Memory Warning does not trigger needed behaviour


#1

Hi, in the book (pg. 178) it is said:

[i]
A view controller will destroy its view if the system is running low on memory and if its view isn’t currently on the screen. Run HypnoTime in the simulator. Select the Time tab so that both views are loaded.

Now, in the simulator, select Simulate Memory Warning from the Hardware menu. This simulates what happens when the operating system is running low on memory and tells your application to clean up stuff it isn’t using.

Switch back to the Hypnosis tab; notice that the console reports that HypnosisViewController loaded its view again[/i]

The thing is even though I followed instructions as above, the behaviour which corresponds to the text I underlined,
does not happen.
Why is this? Is this because maybe I am using iOS 6.1 Simulator? Or Latest XCode?
Thanks.

ps. This does not get called either when I click Simulate Memory Warning when I am on the Hypnosis Tab:

[code]// in TimeViewController

  • (void)viewDidUnload
    {
    [super viewDidUnload];
    NSLog(@“Unloading TimeViewController’s subviews”);
    timeLabel = nil;
    }[/code]

any help?


#2

Same problem, did u try next step(add green color to background)? When I switch back to the Time tab, I still see the green background. :confused:


#3

I’ve seen your posts within the NerdFeed - App you will build during the final chapters of the book. It works - awesome :smiley:

Regarding your question:

This is caused by the new version of Xcode - ViewControllers don’t unload their views anymore, if they receive low memory warnings. So just ignore these parts of the book :slight_smile:

Greetings from Austria!


#4

[quote=“Crumble”]I’ve seen your posts within the NerdFeed - App you will build during the final chapters of the book. It works - awesome :smiley:

Regarding your question:

This is caused by the new version of Xcode - ViewControllers don’t unload their views anymore, if they receive low memory warnings. So just ignore these parts of the book :slight_smile:

Greetings from Austria![/quote]

OK, I see. Actually viewDidUnload - as in my example is deprecated in iOS 6.
One can still implement didReceiveMemoryWarning though, which works I think.

However, one thing that was not working as it was said in the book, if I simulated memory warning while I was on time tab for
example, and then switched to the Hipnosis tab, I would not see the log message which I printed in the viewDidLoad method
of Hipnosis view controller (the book said it should, as the view would get recreated due to being destroyed previously)


#5

Yes, same problem with the green background too.
See also Crumble’s response.


#6

[quote=“user2568508”]
However, one thing that was not working as it was said in the book, if I simulated memory warning while I was on time tab for
example, and then switched to the Hipnosis tab, I would not see the log message which I printed in the viewDidLoad method
of Hipnosis view controller (the book said it should, as the view would get recreated due to being destroyed previously)[/quote]

Like I said, Memory Warnings don’t cause the Controllers to destroy/unload their views anymore.

Edit: You will get the log message, if you implement it in viewWillAppear or viewDidAppear!


#7

[quote=“Crumble”][quote=“user2568508”]

Edit: You will get the log message, if you implement it in viewWillAppear or viewDidAppear![/quote][/quote]
Yes, this I know, thanks.