0
votes

I have a viewController called "FirstViewController". In an IBAction i call another ViewController called "thePageFlipViewController" and push it in sight via

[self presentModalViewController:thePageFlipViewController animated:YES];

after some time the user closes thePageFlipViewController with a button where the following code is executed via a delegate in FirstViewController:

[self dismissModalViewControllerAnimated:YES]; [thePageFlipViewController release];

And here is my problem:

-viewDidLoadin FirstViewController get's sometimes called after dismissing thePageFlipController. I don't understand why, because firstViewController should live in background. Is it dependent how long the modal view is displayed? is it possible that ARC does release something?

My problem is, that i initialise a lot of objects in viewDidLoad and the app crashes if viewDidLoad gets called again. I define some Routes for RESTKit there and RestKit complains that the routes are already set up and crash the app.

Any Help is appreciated.

1
Are you implementing viewDidUnload as well? (if not, you should) - Till
That's what i need to do now! Hoped the View wouldn't be released in background. - MadMaxAPP

1 Answers

1
votes

When a view is not actually displayed it can be unloaded to free up memory. You would get a call to viewDidUnload: when that happens so you can release any objects you are holding strong references to. Then next time the view is needed, viewDidLoad: will get called again when the view is reloaded, there you have to recreate the objects you released in viewDidUnload:.

See the Memory Management section of the UIViewController class reference.

Also this answer has a good explanation already.