I have two arrays, the first one contents numbers and the second one use this numbers as indexes.
NSArray *dayOfWeek = [NSArray arrayWithObjects:@"D",@"L",@"M", @"X",@"J",@"V",@"S", nil];
NSArray *arrayDays = [days componentsSeparatedByString:@" "];
//arrayDays 2 3 4 5 6
NSString *daysPrint;
for (NSString *theDay in arrayDays) {
NSLog(@"string %@",theDay);
NSInteger dayIndex = (NSInteger)theDay;
NSLog(@"integer %d", dayIndex);
daysPrint = [NSString stringWithFormat:@"%@ %@", daysPrint, [dayOfWeek objectAtIndex:dayIndex]];
}
in the log:
2012-07-02 12:49:27.322 usualBike[1698:f803] string 2
2012-07-02 12:49:27.323 usualBike[1698:f803] integer 109471840
And obviously when I try to get dayOfWeek[109461840] it crashes.
How can I solve this?
Thank you in advance
Use this