我想顯示在文本字段中鍵入的數字的每個因子以實現此目的我嘗試使用數組。但我總是得到錯誤'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]];
}
'I <[數組數]' – beryllium 2012-07-25 11:50:59
代碼工作。但它只顯示我的數組中的第一個對象。 – 2012-07-25 12:11:57