I am having some trouble finding help online which makes me think what I am trying to do may not be possible, but I'll ask anyway! I am new to obj-c and I am only developing for a bit of fun...
I am trying to call an array based on a string pulled at random from another array. I have an NSArray called pickerArray which holds the strings: oneArray, twoArray as an example.
I also have NSString (pickerString), NSArray (oneArray) and NSArray (twoArray).
I can randomly pick the string fine, what i can't do is use the values of this sting as 'code'
randomNumber = arc4random()%[pickerString count]; 
pickerString should read as oneArray or twoArray in the code depending on which string
is picked, i.e.
randomNumber = arc4random()%[oneArray count]; 
or:
randomNumber = arc4random()%[twoArray count]; 
depending on the string picked.
Edit: My current code is:
@implementation FirstViewController{
IBOutlet UITextView *doThis;
}
- (IBAction)takeATurn:(id)sender {
int pickerNumber;
int randomNumber;
NSString *pickerString;
NSString *textString;
NSArray *pickerArray;
NSArray *oneArray;
NSArray *twoArray;
pickerArray = [NSArray arrayWithObjects:
               @"oneArray",
               @"twoArray",
               nil];
oneArray = [NSArray arrayWithObjects:
               @"example text to display",
               @"expmple text to display 2",
               nil];
twoArray = [NSArray arrayWithObjects:
               @"example text to display in array two",
               @"expmple text to display in array two 2",
               nil];
pickerNumber = arc4random()%[pickerArray count];
pickerString = [pickerArray objectAtIndex:pickerNumber];
randomNumber = arc4random()%[NSArray(pickerString) count];
     //does not compile - should read [oneArray count]; (or twoArray in place of oneArray
textString = [NSArray(pickerString) objectAtIndex:randomNumber];
     //same as above.
doThis.text = textString;
}
Thanks for any help. Mike
 
     
     
    