From DoorViewController.m // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { DoorFrontViewController *doorFront; DoorBehindViewController *doorBehind; NSString *nibNameFront, *nibNameBehind; NSString *numberOnDoor; NSInteger n; StateOf3Doors *shared3DoorsState = [StateOf3Doors sharedState]; n=shared3DoorsState.numberOfDoors; if(n==3){ nibNameFront=[[NSString alloc] initWithFormat:@"Door%dFrontView",self.doorOrder]; nibNameBehind=[[NSString alloc] initWithFormat:@"Door%dBehindView",self.doorOrder]; } else{ nibNameFront=[[NSString alloc] initWithFormat:@"Door%dof10FrontView",self.doorOrder]; nibNameBehind=[[NSString alloc] initWithFormat:@"Door%dOf10BehindView",self.doorOrder]; } doorFront = [[DoorFrontViewController alloc] initWithNibName:nibNameFront bundle:nil]; doorFront.myParentViewController=self; numberOnDoor = [[NSString alloc] initWithFormat:@"%d",self.doorOrder]; self.doorFrontController = doorFront; [self.view insertSubview:self.doorFrontController.view atIndex:1]; //must load view before accessing label text doorFront.doorNumber.text=numberOnDoor; doorBehind = [[DoorBehindViewController alloc] initWithNibName:nibNameBehind bundle:nil]; self.doorBehindController = doorBehind; [doorFront release]; [nibNameFront release]; [numberOnDoor release]; [nibNameBehind release]; [doorBehind release]; }