I have array (slovoArray) and I am using arc4random to obtain random values. Now I do not know how to get out of numbers (random number is for example 1340), the correct values (name and definition) and then fill them in the two labels. Probably I need a random number obtained from the array somehow decode, but do not know how. Pls help.
This is code in my class RandomViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.slovoArray = [[NSMutableArray alloc] init];
SlovaParser *menuParser = [[SlovaParser alloc] initWithArray51:self.slovoArray];
[menuParser parseXMLFile];
NSLog(@"Number of items in my array is: %lu", [self.slovoArray count]);
NSUInteger randomIndex = arc4random() % [self.slovoArray count];
NSLog(@"Random is: %lu", randomIndex);
self.definiceText.text = [NSString stringWithFormat:@"%@",[self.slovoArray objectAtIndex:randomIndex]];
}
Aucun commentaire:
Enregistrer un commentaire