我想从我的 NSMutableArray 中获取数据,我正在这样做
-(void)ViewDidLoad{
A_array = [[NSMutableArray alloc] init];
A_array = [NSMutableArray arrayWithObjects:@"4",@"6",@"2",@"3",@"0",@"5",@"1",@"2",@"4",@"1",@"0",@"2",@"4",@"2",@"0",@"3",nil]
var_Count_Answer_A = 0; // int
}
-(void)method_Second {
NSLog(@"%@",[A_array objectAtIndex:var_Count_Answer_A]); // This line is crashing if I click button again. First time line works fine but if we click button again and var_Count_Answer = 2 then it will crash.
NSString *str1 = [[NSString alloc]initWithFormat:@"%@",[A_array objectAtIndex:var_Count_Answer_A]]; // If I comment on NSLOG then this line will crash
A = [str1 integerValue];
NSLog(@"A is %d",A);
var_Count_Answer_A ++;
}
如果我试试这个NSLog(@"%@",[A_array objectAtIndex:5]); // works fine
NSLog(@"%@",[A_array objectAtIndex:var_Count_Answer_A]); // var_Count_Answer_A =5; and crash
任何想法或建议将不胜感激。