我该如何创建新的NSMutableArray?
我有一个NSMutableArray只在会话中存在,当前我按照下面的方法创建它:NSMutableArray*temp=[[NSMutableArrayalloc]ini...
我有一个NSMutableArray只在会话中存在,当前我按照下面的方法创建它:NSMutableArray *temp = [[NSMutableArray alloc] initWithCapacity:10]; [self setScoreArray:temp]; [temp release];当我检测索引的时候出现了越界错误:NSNumber *previousScore = [[self scoreArray] objectAtIndex:[self quizNum]]; if ( previousScore != nil ) { [self clearQuizBtns]; NSInteger previousScoreValue = [previousScore integerValue]; [self selectButtonAtTag:previousScoreValue]; }else { [self clearQuizBtns]; }我发现是initWithCapacity没有创建数组。所以,最初我应该如何填入数组数据呢?
展开
1个回答
2013-12-12
展开全部
这段代码给你参考:// scoreDictionary property of NSMutableDictionary class must be declared in selfNSNumber *previousScore = [self.scoreDictionary objectForKey:[NSNumber numberWithInt:[self quizNum]]];if (previousScore != nil) { [self clearQuizBtns]; NSInteger previousScoreValue = [previousScore integerValue]; [self selectButtonAtTag:previousScoreValue];}else { [self clearQuizBtns];}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询