我正在调用一个填充 NSMutableArray 并返回它的方法 getHoleScore。我正在尝试复制数组,以便调用方法可以访问这些项目,但我每次都得到这个异常:
异常'NSRangeException',原因:' * -[__NSArrayM objectAtIndex:]:空数组的索引 0 超出范围'
我尝试了多种不同的方法来复制我在此站点上找到的数组,但似乎没有任何效果。这是代码:
Score *theScore = self.roundScore;
NSMutableArray *scores = [[[self delegate]getHoleScore:self score:theScore] mutableCopy];
NSInteger total = 0;
if (theScore) {
self.playerName.text = theScore.name;
self.courseName.text = theScore.course;
self.hole1Field.text = [NSString stringWithFormat:@"%d", [[scores objectAtIndex:0] integerValue]];
self.hole2Field.text = [NSString stringWithFormat:@"%d", [[scores objectAtIndex:1] integerValue]];
self.hole3Field.text = [NSString stringWithFormat:@"%d", [[scores objectAtIndex:2] integerValue]];
self.hole4Field.text = [NSString stringWithFormat:@"%d", [[scores objectAtIndex:3] integerValue]];
self.hole5Field.text = [NSString stringWithFormat:@"%d", [[scores objectAtIndex:4] integerValue]];
等等
关于如何填充分数数组的任何想法?