Assume filteredArray={ 0,2,3,4}. I have another array called tempArray. I want to insert 1 at zeroth,second,third,fourth position in tempArray.
This code snippet is not working. Any help would be appreciated.
NSMutableArray *tempArray =[[NSMutableArray alloc]init];
// Assume filteredArray={ 0,2,3,4}
for (int i=0 ; i<[filteredArray count] ; i++)
{
[tempArray insertObject:@"1" atIndex:[filteredArray objectAtIndex:i]];
}
to insert objet to array at index, you must have some ojects (not less then index) in array. In different words, you can’t add object at index 5 to array with count 3.
here is solution i advice: