我調用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