Working in Xcode. I can't quite figure this one out. What I'd like to do is have an array of strings "one", "two", "three" etc. I want to be able to have a label which displays one of these strings, chosen at random. Any ideas?
What I've tried so far is this: I've created an array as such:
NSString *yes0 = @"yes";
NSString *yes1 = @"YES";
NSString *yes2 = [NSString stringWithFormat:@"%@", yes1];
NSArray *googleArray = [NSArray arrayWithObjects:yes0, yes1, yes2, nil];
What I'm trying to figure out is how to display an element of this array randomly. I've figured out how to pass a variable to the label which would be as such:
strValue = @"";
yourLabel.text = strValue;
I'm guessing after I have randomly chosen an element from the array, I set strValue equal to that and hence it gets set as my label. I do not understand the random choosing of the string itself.