Bare with me here...
I'm working on a name generator. I want to use (i think) an NSArray of words to serve as a word bank to randomly pick from. It would be 3 separate words to make a funny random name like "Slippery California Farmers" or something.
So I created and positioned a UILabel for each of the 3 words and used:
- (IBAction)buttonClick
id)sender {
NSString *title = nil;
NSString *path = nil;
int Number = rand() % 3;
switch (Number) {
case 0:
myTextLabel1.text = @"Slippery";
myTextLabel2.text = @"California";
myTextLabel3.text = @"Farmers";
break;
case 1:
myTextLabel1.text = @"Raisin";
myTextLabel2.text = @"Hell";
myTextLabel3.text = @"Dudes";
break;
case 2:
myTextLabel1.text = @"Abnormal";
myTextLabel2.text = @"Scissor";
myTextLabel3.text = @"Killers";
break;
}
It shows up fine. But how would I randomize to change the text for each label to pick a different word, creating a new name each time?
And could I create my own invisible word bank to pick from?
Hope you understand what I'm trying to say. I'm new to developing.
Thanks in advance.
I'm working on a name generator. I want to use (i think) an NSArray of words to serve as a word bank to randomly pick from. It would be 3 separate words to make a funny random name like "Slippery California Farmers" or something.
So I created and positioned a UILabel for each of the 3 words and used:
- (IBAction)buttonClick
NSString *title = nil;
NSString *path = nil;
int Number = rand() % 3;
switch (Number) {
case 0:
myTextLabel1.text = @"Slippery";
myTextLabel2.text = @"California";
myTextLabel3.text = @"Farmers";
break;
case 1:
myTextLabel1.text = @"Raisin";
myTextLabel2.text = @"Hell";
myTextLabel3.text = @"Dudes";
break;
case 2:
myTextLabel1.text = @"Abnormal";
myTextLabel2.text = @"Scissor";
myTextLabel3.text = @"Killers";
break;
}
It shows up fine. But how would I randomize to change the text for each label to pick a different word, creating a new name each time?
And could I create my own invisible word bank to pick from?
Hope you understand what I'm trying to say. I'm new to developing.
Thanks in advance.