my problem is that my NSMutableArray
always get the last element with the objectatindex
-method.
I have an array with some classes derived from UIViewController
. I want to show one View after another.
first i fill the array:
ContactViewController *ContactView = [[ContactViewController alloc]init];
QuestionViewController *QuesView = [[QuestionViewController alloc]init];;
ContactView.mydelegate = self;
[QuesView setDelegate:self];
[Views addObject:ContactView];
Views =[[NSMutableArray alloc]initWithCapacity:11];
for (int i = 0; i < 11; i++) {
[QuesView setParam:@"text" :i ];
[Views addObject:QuesView];
}
after that i want to get the actual view and jump to the next like that:
-(IBAction)Button:(id)sender
{
UIViewController *newView = [[UIViewController alloc]init];
newView = (UIViewController*)[Views objectAtIndex:enumerator];
[self presentViewController:newView animated:YES completion: nil];
enumerator++;
//dismiss old view here....
NSLog(@"number %d",[newView getNumber]);
}
the new view is not shown and the number in the log is always the last number of the array. I tried to go with a for loop through all element in "Views" but there is always the last number in every object....
any hints?