我正在尝试显示一个数组,其中包含数字(“prime”)的不同因子。但不是给我的int数,我总是得到0,1,2,3,4,5,...。在xcode中显示数组
factors.text = @"";
int factorsNumber;
NSMutableArray *array;
array = [NSMutableArray arrayWithCapacity:5];
for (factorsNumber=1; factorsNumber<=prime; factorsNumber++) {
if (prime%factorsNumber == 0) {
[array addObject:[NSString stringWithFormat:@"%d", factorsNumber]];
}
}
for (int i = 0; i < [array count]; i++) {
[array replaceObjectAtIndex:1 withObject:@"4"];
NSString *temp = [NSString stringWithFormat:@"%d, ", i, [[array objectAtIndex:i] intValue]];
factors.text = [factors.text stringByAppendingString:temp];
}
什么类型是'总理'? – Weston 2012-07-25 13:11:11
它是一个整数 – 2012-07-25 13:12:02