I'm just starting iOS programming and am playing around with trying to switch view controllers programatically (i.e. go from one view to another). I know that the view controller that presents the next view controller needs to be released after the other one is presented but I can't seem to get anything that works. I have tried dismissing the controller after presenting the next controller but I still get a memory leak.
So I have this code in ViewControllerA
:
- (void) switchViews {
[self presentViewController:[[ViewControllerB alloc] init] animated:NO completion:nil];
}
and this in ViewControllerB
:
- (void) switchViews {
[self presentViewController:[[ViewControllerA alloc] init] animated:NO completion:nil];
}
Buttons in the views fire these events and basically they just switch from one view to the other.
So how do I switch views back and forth so that a memory leak isn't created? And as a side note I am using ARC.