UICollectionView가있는 iPhone 응용 프로그램에서 작업 중이며 iPhone 스프링 보드와 같은 폴더를 만들려고합니다. 나는 그것이 작동하지만 핵심 데이터를 사용하는 셀의 덧셈과 뺄셈과 관련하여이 오류가 발생했습니다. 누군가이 오류를 피하는 방법을 설명 할 수 있기를 바랬습니다. 미리 감사드립니다. '잘못된 업데이트 : 때문에 캐치되지 않는 예외'NSInternalInconsistencyException '응용 프로그램 종료, 이유UICollectionView 잘못된 요소 수, 요소 추가 및 삭제
* 기존 섹션에 포함 된 항목의 개수 업데이트 후 단면 0 항목 수가 잘못 (4)와 동일해야 업데이트 전에 해당 섹션에 포함 된 항목 수 (3), 해당 섹션에서 삽입 또는 삭제 된 항목 수를 더한 값 (0이 삽입 됨, 0이 삭제됨) 및 해당 섹션으로 들어오고 나가는 항목 수를 더한 값 또는 빼기 값 (0은 안으로 움직 였고 0은 밖으로 움직였다). '
------ mainViewController
//**Document One**
//get first doc and create it as a sub doc
Document * docToCopy = [[self birds] objectAtIndex:longPressFolderLayout.pinchedCellPath.row];
SubDocument *doc = [[SubDocument alloc] initInsertingIntoManagedObjectContext:managedObjectContext];
[doc setTitle:docToCopy.title];
[doc setThumbnail:docToCopy.thumbnail];
[doc setIsFolder:[NSNumber numberWithInt:0]];
[doc setDate:docToCopy.date];
//**Document Two**
//get second doc and create it as a sub doc
Document * docToCopy2 = [[self birds] objectAtIndex:cellAttributes.indexPath.row];
SubDocument *doc2 = [[SubDocument alloc] initInsertingIntoManagedObjectContext:managedObjectContext];
[doc2 setTitle:docToCopy2.title];
[doc setThumbnail:docToCopy2.thumbnail];
[doc2 setIsFolder:[NSNumber numberWithInt:0]];
[doc2 setDate:docToCopy2.date];
[self add:@"folder" image:[UIImage imageNamed:@"folderDefaultImage"] date:[NSDate date] folder:[NSNumber numberWithInt:1]];
//**Folder**
//create a folder and append both sub docs and then remove the original docs
Document * origFolder = [[self birds] objectAtIndex:([[self birds]count]-1)];
[origFolder appendDoc:doc];
[origFolder appendDoc:doc2];
[origFolder setIsFolder:[NSNumber numberWithInt:1]];
currentOpenFolder = origFolder;
[self removePageAtIndex:longPressFolderLayout.pinchedCellPath.row];
[self removePageAtIndex:cellAttributes.indexPath.row];
------ DocumentNSManagedObject
오류 메시지가UICollectionView
당신은 같은 그것을 제공하는 정보와 함께 할 것입니다
- (void)appendDoc:(SubDocument *)doc
{
[[self mutableSetValueForKey:@"subDocument"] addObject:doc];
[(NSMutableArray *)[self subDocumentsOrdered] addObject:doc];
NSError *error = nil;
[[self managedObjectContext] save:&error];
}
- (void)deleteDoc:(SubDocument *)doc
{
[[self mutableSetValueForKey:@"subDocument"] removeObject:doc];
[(NSMutableArray *)[self subDocumentsOrdered]removeObject:doc];
NSError *error = nil;
[[self managedObjectContext] save:&error];
}
- (NSArray *)subDocumentsOrdered
{
if (!subDocumentsOrdered)
{
subDocumentsOrdered = [[[[self subDocument] allObjects] sortedArrayWithOptions:NSSortStable|NSSortConcurrent usingComparator:(NSComparator) ^(SubDocument *stroke1, SubDocument *stroke2)
{
return [[stroke1 date] compare:[stroke2 date]];
}
] mutableCopy];
}
return subDocumentsOrdered;
}
문제의 원인과 그 원인을 알고 있습니까? 그렇다면이 질문/답변을 개선하여 여기에 세부 정보를 추가하십시오. –
예를 들어 여기에 표시된 세이브는 오류를 제거하는 동안 앱을 개발하거나 기기에서 테스트 할 때 문제가 될 수있는 최상의 성능을 내지 못할 수도있는 뷰의 전체 재구성을 트리거 할 수 있습니다. –