나는 이것으로 절대 bamboozled과 내가 무엇을 놓치지 알아낼 수 없습니다. 아마도 핵심 데이터에 대해 많은 것을 배울 수 있습니다.섹션 가져 오기 결과 컨트롤러 나누기 검색 디스플레이
이 섹션이없는 테이블 만 내 검색 디스플레이 컨트롤러 작동 표시 내 반입 결과 컨트롤러입니다 : 최대한 빨리이 sectionNameKeyPath을 적용 할 때 반면
self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request
managedObjectContext:self.buckyballDatabase.managedObjectContext
sectionNameKeyPath:nil
cacheName:nil];
섹션을 추가합니다.
- (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;
}
}
- : filteredList가있는 NSArray 인 경우
*** 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])'
그리고 여기 내 테이블보기 데이터 소스 구현 있습니다 : 아래의 오류를 던지고, 섹션이 추가됩니다하지만 내 검색 디스플레이 컨트롤러가 고장 다음 행의 cellForRowAtIndexPath에 예외가 발생합니다. -
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
필요가 더 많은 정보를 제공 할 수 있는지 문의주세요 .. 나는
를 사용해보십시오이 하나에 너무 많은 내 머리를 .. 긁적 해요 :'가 아니라' -dequeueReusableCellWithIdentifier : forIndexPath :'. – chris
@chris에 감사드립니다 ... 검색 디스플레이 컨트롤러가 작동합니다. 그러나 코어 데이터의 모든 업데이트 (삭제 쌍)는 인덱스와 섹션 이름을 제외한 모든 데이터가 사라지도록 테이블을 손상시킵니다. 문제는 sectioning과 indexing없이 작동합니다 :-(오류 : CoreData : error : 심각한 응용 프로그램 오류 -controllerDidChangeContent : *** - [__ NSArrayM insertObject : atIndex :] 호출 중에 NSFetchedResultsController 대리자에서 예외가 발견되었습니다. : object는 userInfo (null)로 nil이 될 수 없습니다. –
사용해보기 : http://stackoverflow.com/questions/3077332/how-to-refresh-a-uitableviewcontroller-or-nsfetchedresultscontroller – MCKapur