so I have this method that returns a letter (from A-Z) by creating a random number between 1-26 and then indexing a string array to pull out the letter. The only problem is that it does not generate a new letter when the method is called. How can I generate a new letter every time the method is called, like in a while loop. Here is my code:
-(NSString *)alphaGenerator{
NSUInteger randomLetterInteger = arc4random_uniform(26);
NSArray *alphabet = @[@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z"];
NSString *alpha = alphabet[randomLetterInteger];
return alpha;
}
Also, how do I convert a number that is returned from the count method into a number that I can plug into the arc4random_uniform method? I receive the 'incompatible integer to pointer inversion initializing...' error. This is what I have for this:
-(NSUInteger)numOfDictions{
NSString *alpha = [self alphaGenerator];
NSUInteger numb = [cuisines[alpha] count];
NSUInteger *randomNumOfDictions = arc4random_uniform(numb);
return *randomNumOfDictions;
}