i 尝试使用1至30个数字的阵列。
NSMutableArray *numberOfdaysInAMonth = [[NSMutableArray alloc] init ] ;
for ( i=0; i< 30; i++){
[numberOfdaysInAMonth addObject:[NSNumber numberWithInteger:i+1]];
NSLog (@"Element_numberofDaysinAMonth %i = %@", i, [numberOfdaysInAMonth objectAtIndex: i]);
}
我有35个部分,其价值为:
NSMutableArray *latestArrayForMonth = [[NSMutableArray alloc]init ];
for ( i=0; i<36; i++){
[latestArrayForMonth addObject:[NSNull null]];
}
现在,我要将OfDaysInAMonth的数值从指数:1中插入:
for (i = 0; i < 30; i++){
[latestArrayForMonth insertObject:[numberOfdaysInAMonth objectAtIndex:i] atIndex:1];
NSLog (@"Element_latestArrayForMonth %i = %@", i, [latestArrayForMonth objectAtIndex: i]);
}
“康索尔”的输出是:
Element_latestArrayForMonth 0 = <null>
Element_latestArrayForMonth 1 = 2
Element_latestArrayForMonth 2 = 2
Element_latestArrayForMonth 3 = 2
Element_latestArrayForMonth 4 = 2
Element_latestArrayForMonth 5 = 2
.
.
.
Element_latestArrayForMonth 28 = 2
Element_latestArrayForMonth 29 = 2
Why am I getting all 2s on the output?