I am currently trying to sort out some logic to check an array for any values.. if there are no values I want to restrict what cells the user can access in the tableview, so they don’t waste their time trying to display values that are not there.
This is what my parser delegate code looks like
- (void)parserDidEndDocument:(NSXMLParser *)parser
{
if (dataSetToParse == @"Id"){
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@",@"ID",IdString]; //RestrictionString is being set from the sub view when the user makes a Ig selection
NSArray *filteredArray = [parsedDataArrayOfDictionaries filteredArrayUsingPredicate:predicate];
if ([filteredArray count] == 0)
{
self.removeActivityIndicator = NO; // sets indicator to be turned off once tableview has been reloaded, (tableView:cellForRowAtIndexPath:)
NSLog(@"1"); //THIS IS WHERE IT REPEATS FOR EVER
}
else if([filteredArray count] !=0)
{
IdFilterMutableArray = [filteredArray mutableCopy];
NSLog(@"%@", IdFilterMutableArray);
}
[self.tableView reloadData]; //Reloads the tabel delegate methods
//TODO: add loading timer here
}
}
parsedDataArrayOfDictionaries is a big cached array of dictionaries, each dictionaty has an id, a previous selection sets the id value and the value gets restricted fine and will display the correct information.. but if filteredArray coun == 0 then it spits the dummie…
heres the output.
2012-01-25 09:30:48.987 Code[860:207] 1
2012-01-25 09:30:49.072 Code[860:207] 1
2012-01-25 09:30:49.155 Code[860:207] 1
2012-01-25 09:30:49.235 Code[860:207] 1
2012-01-25 09:30:49.316 Code[860:207] 1
2012-01-25 09:30:49.398 Code[860:207] 1
2012-01-25 09:30:49.479 Code[860:207] 1
2012-01-25 09:30:49.587 Code[860:207] 1
2012-01-25 09:30:49.669 Code[860:207] 1
2012-01-25 09:30:49.750 Code[860:207] 1
2012-01-25 09:30:49.840 Code[860:207] 1
2012-01-25 09:30:49.924 Code[860:207] 1
2012-01-25 09:30:50.011 Code[860:207] 1
2012-01-25 09:30:50.102 Code[860:207] 1
2012-01-25 09:30:50.188 Code[860:207] 1
2012-01-25 09:30:50.275 Code[860:207] 1
2012-01-25 09:30:50.360 Code[860:207] 1
In your tableview delegate methods (either num rows per section or tableViewCellForRowAtIndexPath etc) are you parsing the xml?
If you are then the the call to
[self.tableView reloadData]is probably making it parse everything again 🙂If you’re not then I don’t know, sorry 🙁