please tell me meaning of following code
this code is function of 1st view which is directing to 2nd view…
but i dont know the meaning
- (IBAction)switchPage:(id)sender
{
if(self.viewTwoController == nil)
{
ViewTwoController *viewTwo = [[ViewTwoController alloc]
initWithNibName:@"View2" bundle:[NSBundle mainBundle]];
self.viewTwoController = viewTwo;
[viewTwo release];
}
[self.navigationController pushViewController:self.viewTwoController animated:YES];
}
switchPage is an action that is being invoked by an UI element in view 1, most probably a button or a table cell.
The method first checks if the viewTwoController property of the current object is null. if It is, it allocates a new instance of ViewTwoController class, specifying “View2” as the name of the .nib file to load in order to create the corresponding view for the new controller instance. Once the instance is created, it is assigned to the property, and the the local retain count is released, so that the new controller is kept alive only by the retain count of the class property.
Once the method has ensured that the viewTwoController has a valid instance, it directs the navigation controller to push the view for the viewTwoController to the top of the views stack and make it active.