Push to View Controller based on String
A ===>VC
.M File
-(void) push
{
VCName *vcobj=[[VCName alloc]initWithNibName:@"VCName" bundle:nil];
[vcobj setPageString:@"SelectVC"];
[self.navigationController vcobj animated:YES];
// Example
ArriveTicketViewController *arrivelView=[[ArriveTicketViewController alloc]initWithNibName:@"ArriveTicketViewController" bundle:nil];
[arrivelView setPageString:@"SelectVC"];
[self.navigationController pushViewController:arrivelView animated:YES];
}
B ====> VC
.h File
{
NSString *pageString;
}
@property(nonatomic,strong) NSString *pageString;
.M File
@synthesize pageString;
if([self.pageString isEqualToString:@“SelectVC”])
{
// perform action
}
Poping the ViewController
-(void)PopToVC
{
for (UIViewController *viewcontroller in [self.navigationController viewControllers])
{
if ([viewcontroller isKindOfClass:[VCName class]])
{
VCNameobj =(VCName *)viewcontroller;
VCNameobj.pageString=@"SelectVC";
[self.navigationController popToViewController:viewcontroller animated:YES];
}
}
}