I am trying to add nsindexpath into an array .. i am able to add only one indexpath .if i try to add another indexpath into array ..the debugger shows only the newest indexpath .
for (int i = 0 ; i<[notificationArray count]; i++)
{
selectedSymptIndexPath = [NSIndexPath indexPathForRow:selectedSymptomIndex inSection:keyIndexNumber];
selectedSympIPArray = [[NSMutableArray alloc]init];
[selectedSympIPArray addObject:selectedSymptIndexPath];
}
even if i try to put [selectedSympIPArray addObject:selectedSymptIndexPath];
outside for loop still its adding only the newest indexpath rather than showing multiple indexpaths
You are alloc init'ing the array every time in the loop, dont do that.
Try this:
selectedSympIPArray = [[NSMutableArray alloc]init];
for (int i = 0 ; i<[notificationArray count]; i++)
{
selectedSymptIndexPath = [NSIndexPath indexPathForRow:selectedSymptomIndex inSection:keyIndexNumber];
[selectedSympIPArray addObject:selectedSymptIndexPath];
}
In your code , you alloc every time in iteration. It's totally wrong. Find your mistake.
You can use this code....
selectedSympIPArray = [NSMutableArray array];
for (int i = 0 ; i<[notificationArray count]; i++)
{
selectedSymptIndexPath = [NSIndexPath indexPathForRow:selectedSymptomIndex inSection:keyIndexNumber];
[selectedSympIPArray addObject:selectedSymptIndexPath];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With