I'm trying to check if a viewcontroller has already been created. If the view already exists then it should become the current view. If it doesn't exist then it should be created and made visible.
My code is
DemoViewController *demoController = [DemoViewController alloc];
for(DemoViewController *view in self.navigationController.viewControllers)
{
if([view isKindOfClass:[DemoViewController class]])
{
viewExists=true;
demoController=view;
}
}
if (!viewExists) {
demoController initWithNibName:@"DemoViewController" bundle:nil;
}
[view release];
[demoController release];
I'm not sure where I'm going wrong but it would appear that the for loop isn't being executed. Any help would be great!
Try like this: