我完全被这个所困扰,无法解决我所缺少的问题.也许还有很多东西需要了解核心数据.
这是我的Fetched Results Controller,它显示了一个无节表,但我的搜索显示控制器工作:
self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedobjectContext:self.buckyballDatabase.managedobjectContext sectionNameKeyPath:nil cacheName:nil];
鉴于我应用sectionNameKeyPath,添加部分.部分被添加但我的搜索显示控制器坏了,抛出以下错误:
*** Assertion failure in -[UITableViewRowData rectForRow:inSection:],/SourceCache/UIKit_Sim/UIKit-2372/UITableViewRowData.m:1630 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException',reason: 'request for rect at invalid index path (<NSIndexPath 0x7481040> 2 indexes [0,1])'
这里是我的表视图数据源实现其中filteredList是NSArray: –
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { if (tableView == self.tableView) { return [[self.fetchedResultsController sections] count]; } else { return 1; } } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (tableView == self.tableView) { return [[[self.fetchedResultsController sections] objectAtIndex:section] numberOfObjects]; } else { return [self.filteredList count]; } } - (Nsstring *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if (tableView == self.tableView) { return [[[self.fetchedResultsController sections] objectAtIndex:section] name]; } else { return nil; } } - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(Nsstring *)title atIndex:(NSInteger)index { if (tableView == self.tableView) { if (index > 0) { return [self.fetchedResultsController sectionForSectionIndexTitle:title atIndex:index-1]; } else { self.tableView.contentOffset = CGPointZero; return NSNotFound; } } else { return 0; } } - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { if (tableView == self.tableView) { NSMutableArray *index = [NSMutableArray arrayWithObject:UITableViewIndexSearch]; NSArray *initials = [self.fetchedResultsController sectionIndexTitles]; [index addobjectsFromArray:initials]; return index; } else { return nil; } }
在以下行的cellForRowAtIndexPath中抛出异常: –
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
请问是否需要提供更多信息..我在这个问题上摸不着头脑.
解决方法
尝试使用-dequeueReusableCellWithIdentifier:而不是-dequeueReusableCellWithIdentifier:forIndexPath:.
原文地址:https://www.jb51.cc/c/118982.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。