我想显示在文本字段中键入的数字的每个因子以实现这一点,我尝试使用数组。但我总是收到错误'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
。有什么建议可以消除这个错误吗?
NSMutableArray *array;
array = [NSMutableArray arrayWithCapacity:100];
for (factorsNumber=1; factorsNumber<=number; factorsNumber++) {
if (number%factorsNumber == 0) {
[array addObject:[NSString stringWithFormat:@"%d", factorsNumber]];
}
}
for (int i = 0; i <= [array count]; i++) {
factors.text = [NSString stringWithFormat:@"%d", i, [[array objectAtIndex:i] intValue]];
}