Reputation: 2487
I have an NSMutableArray;
array=(
{
names=a;
score=2;
},
{
names=b;
score=5;
},
{
names=c;
score=20;
}
)
First I want to test if the score is greater than 10, then display all the values in a tableview;
I'm having hard time how to access the array, I'm coming from a PHP's view point so I really don't have any clues
I'm getting a SIGABRT with
cell.textLabel.text = [self.array objectAtIndex:indexPath.row];
I presume because I haven't digest the array or I'm passing the whole array content into the cell which might be choking and spitting it out.
Could somebody please help?
Upvotes: 0
Views: 74
Reputation: 1326
Best is to rewrite your array to new one to avoid overhead of doing it in every cell.
You can do it for instance in viewDidLoad
like that:
- (void)viewDidLoad {
self.filteredArray = [[NSMutableArray alloc] init];
for (ArrayElement *arrayObject in self.array)
{
if ([[arrayObject score] intValue] > 10)
{
[self.filteredArray addObject:arrayObject];
}
}
}
Then use self.filteredArray
in your tableView
delegates.
Upvotes: 2