- (NSInteger)numberOfSectionsIntableVIEw:(UItableVIEw *)tableVIEw{ // Return 1 if the fetchedResultsController section count is zero return [[fetchedResultsController sections] count] ? : 1;}- (Nsstring *)tableVIEw:(UItableVIEw *)tableVIEw TitleForheaderInSection:(NSInteger)section { // check if we really have any sections in the managed object: if (!fetchedResultsController.sections.count) return @"Persoonlijk"; ID <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section]; return [sectionInfo name];}- (NSInteger)tableVIEw:(UItableVIEw *)tableVIEw numberOfRowsInSection:(NSInteger)section{ // check if we really have any sections in the managed object: if (!fetchedResultsController.sections.count) return 0; ID <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section]; return [sectionInfo numberOfObjects];}
更新
行被删除的方法:
- (voID)tableVIEw:(UItableVIEw *)tableVIEw commitEditingStyle:(UItableVIEwCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UItableVIEwCellEditingStyleDelete) { // Delete schedule NSManagedobjectContext *context = [fetchedResultsController managedobjectContext]; [context deleteObject:[fetchedResultsController objectAtIndexPath:indexPath]]; // Save the context. NSError *error = nil; if (![context save:&error]) { NSLog(@"Unresolved error %@,%@",error,[error userInfo]); exit(-1); } } }解决方法 我找到了问题/解决方案:
对于这种情况,我没有必需的dIDChangeSection委托方法!
- (voID)controller:(NSFetchedResultsController *)controller dIDChangeSection:(ID <NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {NSLog(@"dIDChangeSection"); switch(type) { case NSFetchedResultsChangeInsert: [self.tableVIEw insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UItableVIEwRowAnimationFade]; break; case NSFetchedResultsChangeDelete: [self.tableVIEw deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UItableVIEwRowAnimationFade]; break; }}总结
以上是内存溢出为你收集整理的objective-c – 使用NSFetchedResultsController删除节中的最后一行 – >崩溃全部内容,希望文章能够帮你解决objective-c – 使用NSFetchedResultsController删除节中的最后一行 – >崩溃所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)