vendredi 15 avril 2016

How can i load in a label a string from two different arrays randomly

sorry for my bad english. I want to show in a label a string, that is taken from two different arrays randomly...so i've got two arrays:

@property (strong, nonatomic) NSArray *indPres;
@property (strong, nonatomic) NSArray *indImp;

self.indPres = [[NSArray alloc] initWithObjects:
                   @"laudo",
                   @"moneo",
                   @"facio",
                   @"videor", nil];
self.indImp = [[NSArray alloc] initWithObjects:
                           @"lodo",
                           @"rimango",
                           @"faccio",
                           @"sono visto", nil];

And that's how i take random string from one array:

NSUInteger daprendere = (arc4random() % 4);
NSLog(@"indice estratto: %lu", (unsigned long)daprendere);

[self.label setText:[self.indPres objectAtIndex:daprendere]];

But if i want to take randomly in the same time from the two arrays how can i do? I mean i want only one string but taken randomly from one of these two arrays




Aucun commentaire:

Enregistrer un commentaire