user2037857
user2037857

Reputation: 83

Restart ViewController

For testing and writing code I need to restart my GameViewContrller

GameViewController *controller = [[GameViewController alloc] initWithNibName:@"GameViewController" bundle:nil];
[self presentModalViewController:controller animated:NO];

This method restart viewController but all stored in memory because of my actions / processes going on, as in the application memory increases with each not reboot.     I think this is not the correct way, and would like to know how, overburden viewController entirely so with memory, delete all the process and start again.

update

- (IBAction)restartButtonPress {
  //  GameViewController *controller = [[GameViewController alloc] initWithNibName:@"GameViewController" bundle:nil];
  //  [self presentModalViewController:controller animated:NO];

[self.view setNeedsDisplay];
}

Upvotes: 3

Views: 4313

Answers (2)

iPatel
iPatel

Reputation: 47059

Call [self.view setNeedsDisplay]; that use for reload you view. alos you can use [self viewDidLoad] method but it is not good for us and also we don't call viewDidLoad manually. so you can use setNeedsDisplay.

Upvotes: 2

mr.VVoo
mr.VVoo

Reputation: 2270

This only starts a new one. It doesn't reset the old one.

To delete the old one you need to call [controller release] to the old one.

Upvotes: 0

Related Questions