0

알아낼 수없는 이상한 문제가 있습니다. 꽤 UIViewControllerUITableView이고 NSFetchedResultsController은 SQLite 저장소에서 가져 오는 개체입니다. 페치 잘 작동 테이블은 전형적인 NSFetchedResultsController 보일러와 함께 잘 작동 : 나는 데 문제가이유없이 가져온 결과에서 관리 객체가 제거되었습니다.

-(void)controllerWillChangeContent:(NSFetchedResultsController *)controller{ 

    [self.tableView beginUpdates]; 
} 
-(void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type{ 

    if(type==NSFetchedResultsChangeInsert){ 
     [self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade]; 
    } else if(type==NSFetchedResultsChangeDelete){ 
     [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade]; 
    } 

} 
-(void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath{ 

    UITableView *tV = self.tableView; 
    if(type==NSFetchedResultsChangeInsert){ 
     [tV insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade]; 
    } else if(type==NSFetchedResultsChangeDelete){ 
     [tV deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
    } else if(type==NSFetchedResultsChangeUpdate){ 
     [self configureCell:[tV cellForRowAtIndexPath:indexPath] atIndexPath:indexPath]; 
    } else if(type==NSFetchedResultsChangeMove){ 
     [tV deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
     [tV insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade]; 
    } 

} 
-(void)controllerDidChangeContent:(NSFetchedResultsController *)controller{ 
    [self.tableView endUpdates]; 
} 

그 관계 속성이 인출 요청에 포함되지 않은 경우에도 (전무 어떤 관계 객체 술어 또는 정렬 설명자에서) 어떤 식 으로든 업데이트 될 때마다 (예 : 관련없는 속성 변경) 가져온 결과 (이 NSFetchedResultsChangeDelete과 함께 호출 됨)에서 사라집니다. 가져 오기를 다시 수행하면 개체가 다시 나타납니다.

이렇게하면 가져 오기 요청에 조건자를 사용하지 않아도 발생합니다.

아무도 여기에서 무슨 일이 벌어지고 있는지 알 수 있습니까?

+0

항상 이유가 있습니다. 반역죄와 같은 것이 없습니다. D – tGilani

+0

운율에 감사드립니다. –

+0

엔티티/속성/관계에 대한 설명을 추가하고 가져온 결과 컨트롤러를 만드는 방법에 대한 코드도 표시해야합니다. –

답변

0

내 NSFetchedResultsController에서 내 sectionNameKeyPath를 변경하여이 문제를 해결할 수있었습니다. sectionNameKeyPath 등록 정보가 선택적 관계 등록 정보이면 제거하거나 변경하십시오.

실제로 섹션을 구분할 때 해당 속성을 사용하려면 nil을 나타내는 데 "더미"개체를 사용해야 할 수도 있습니다. (사실상 당신이 당신의 섹션을 위해 그것을 사용하게된다면 속성은 옵션이 될 수 없다는 것을 의미합니다.)

+0

이것은 문제가 무엇인지 이해하기 전까지는 진정한 해결책이 아닙니다. –

+0

문제는 NSFetchedResultsController의 sectionNameKeyPath가 선택적이므로 (일부 개체의 경우 nil이기 때문입니다.) 해결책이 아닐 수도 있지만 최소한 문제에 대한 설명입니다. – MikecheckDev