Hello. I need some help passing an array to another class for use. To keep it simple ill only give 2 of my classes, but just in case more coding is needed, this array is going to be used for around 50 classes.
So i have HowToPlay.h (which of course has a .m) the array is set up in HowToPlay.
Then i also have another class called Question 1.h (of course has a .m). This class is a subClass of HowToPlay, and i have also imported HowToPlay into this class.
Now let me explain a bit about this array. This array is being used to select a random NIB file, and then if the NIB has already been used before it deletes it from the array.
The array itself looks like this (this is in HowToPlay)
Code:
nibs = [[NSMutableArray alloc]initWithObjects:@"Question 2", @"Question 3", nil];
self.unusedNibs = nibs;
[nibs release];
Hopefully your not confused when you see the Question 2 and Question 3, just ignore them, their irrelevant.
Now lets jump into Question 1,
Inside Question 1 I have a IBAction that uses this array, it looks something like this
Code:
-(IBAction)continueAction:(id)sender{
random = arc4random() % [self.unusedNibs count];
NSString *nibName = [self.unusedNibs objectAtIndex: random];
[self.unusedNibs removeObjectAtIndex: random];
if (nibName == @"Question 3") {
Question_3 *Q3 = [[Question_3 alloc] initWithNibName:@"Question 3" bundle:nil];
Q3.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:Q3 animated:YES];
[Q3 release];
}
if (nibName == @"Question 2") {
Question_2 *Q2 = [[Question_2 alloc] initWithNibName:@"Question 2" bundle:nil];
Q2.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:Q2 animated:YES];
[Q2 release];
}
}
Again the Question 2 and Question 3 parts of this code are irrelevant. So as you can see the code picks a random NIB to load, then deletes it from the array. The problem is, its not deleting it from the array.
I think the array isnt be passed to the other class. Any Ideas?
The app runs fine, but it still loads those NIBs that should have been deleted out of the array.
Thanks,
Jacob