i try to make an array that has the numbers from 1 to 30 using..
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]);
}
and I have an array with 35 elements and they have the value of null:
NSMutableArray *latestArrayForMonth = [[NSMutableArray alloc]init ];
for ( i=0; i<36; i++){
[latestArrayForMonth addObject:[NSNull null]];
}
Now I want to insert the values from numberOfDaysInAMonth into the LatestArrayWithMonth statrting from index:1 using:
for (i = 0; i < 30; i++){
[latestArrayForMonth insertObject:[numberOfdaysInAMonth objectAtIndex:i] atIndex:1];
NSLog (@"Element_latestArrayForMonth %i = %@", i, [latestArrayForMonth objectAtIndex: i]);
}
Output on the Console is:
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?