我目前正在尝试整理一些逻辑以检查数组中的任何值..如果没有值我想限制用户可以在tableview中访问哪些单元格,这样他们就不会浪费时间试图显示不存在的值。
这是我的解析器委托代码的样子
- (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是一个大型缓存的字典数组,每个字典都有一个id,前一个选择设置id值,值得到限制并显示正确的信息..但是如果filteredArray coun == 0那么它会吐出dummie ...
继承人的输出。
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
答案 0 :(得分:0)
在你的tableview委托方法(每个部分的num行或tableViewCellForRowAtIndexPath等)你解析xml?
如果您是[self.tableView reloadData]
,那么可能会再次解析所有内容:)
如果你不是那么我不知道,抱歉:(