I am trying to use a loop to print out the contents of 26 arrays, rather than printing out each in turn.
The problem I am having is in the NSLog below where I call the specific array. I am trying to use the "stringName" string to specify which array I want to count.
….list of arrays starting at beginWithA….
NSArray *beginWithT = [randomList filteredArrayUsingPredicate:tPredicate];
NSArray *beginWithU = [randomList filteredArrayUsingPredicate:uPredicate];
NSArray *beginWithV = [randomList filteredArrayUsingPredicate:vPredicate];
NSArray *beginWithW = [randomList filteredArrayUsingPredicate:wPredicate];
NSArray *beginWithX = [randomList filteredArrayUsingPredicate:xPredicate];
NSArray *beginWithY = [randomList filteredArrayUsingPredicate:yPredicate];
NSArray *beginWithZ = [randomList filteredArrayUsingPredicate:zPredicate];
NSString *alphabet = @"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (int i =0; i<26; i++)
{
unichar c = [alphabet characterAtIndex:i];
NSString *stringName = [NSString stringWithFormat:@"beginWith%C", ch];
NSLog (@"The %C Array contains %lu words.", [stringName count]);
}
I know that just dropping the string name into the spot thats looking for an array won't work but for the sake of clarity here this seemed best. Ive tried many variations and options.
I understand that this may not be a good way to go, but I'm so close! Any help would be greatly appreciated.
thanks ~Steve