我调用getHoleScore方法来填充NSMutableArray并返回它。我试图阵列复制,以便调用方法可以访问该项目,但每一次我得到这个异常:Objective-C:复制返回的NSMutableArray
异常“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]];
等
如何填充分数阵列的任何想法?
如果你调用NSLog(@“%@”,得分),那么''NSMutableArray * scores'声明之后呢? –
我只是得到一个开放的括号,然后是相同的异常。 – user1040854
在哪一行你会得到这个异常?你能告诉我们getHoleScore的定义吗? – nagan