我正在尝试将文件的内容传递到一个数组中,然后由随机图像生成器调用该数组。我错过了一些东西(或很多东西)。有任何想法吗?
NSString *chords = [[NSBundle mainBundle] pathForResource:@"ChordCharts" ofType:nil];
chordCharts = [NSMutableArray arrayWithContentsOfFile:chords];
int randomimages = rand() % 4;
switch (randomimages) {
case 0:
chordImage.image = [UIImage imageNamed:[chordCharts objectAtIndex:0]];
break;
case 1:
chordImage.image = [UIImage imageNamed:[chordCharts objectAtIndex:1]];
break;
case 2:
chordImage.image = [UIImage imageNamed:[chordCharts objectAtIndex:2]];
break;
case 3:
chordImage.image = [UIImage imageNamed:[chordCharts objectAtIndex:3]];
break;
default:
break;
}