GuybrushThreepwood
GuybrushThreepwood

Reputation: 5616

Dismiss / Present Modal View Controller - Memory?

When you dismiss a modal view controller is that view controller object destroyed ?

Also if you represent the same view controller again does it load from fresh - e.g is the "view did load" and "init" method called ?

Upvotes: 5

Views: 5858

Answers (1)

Philippe Leybaert
Philippe Leybaert

Reputation: 171914

Releasing objects is your own responsibility, so you should release the view controller yourself, either after calling presentModalViewController, or sometime later (not recommended)

For example:

MyController *controller = [[MyController alloc] init];

[self presentModalViewController:controller animated:YES];

// "controller" is automatically retained, so you can call release right away    

[controller release];

Calling dismissModalViewController later on will release the retained controller automatically.

Upvotes: 3

Related Questions