加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ios – 在交换机中未处理枚举值’NSFetchedResultsChangeMove’

发布时间:2020-12-14 19:00:20 所属栏目:百科 来源:网络整理
导读:我收到这个警告: 在交换机中未处理枚举值’NSFetchedResultsChangeMove’和NSFetchedResultsChangeUpdate’ 有任何想法吗? - (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id NSFetchedResultsSectionInfo)sectionInfo a
我收到这个警告:
在交换机中未处理枚举值’NSFetchedResultsChangeMove’和NSFetchedResultsChangeUpdate’

有任何想法吗?

- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {
    switch(type) {
        case NSFetchedResultsChangeInsert:
            [self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}

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

提前致谢

解决方法

编译器知道NSFetchedResultsChangeType有四个可能的值,但是您的代码只处理其中的两个.如果您确定不会发生其他两个,则可以忽略该警告.但是最安全的做法是包含一些代码来处理这些其他值,无论是什么都没有,或者是NSLog来查看它们是否确实发生.我想补充一下

case NSFetchedResultsChangeMove:
    NSLog(@"A table item was moved");
    break;
case NSFetchedResultsChangeUpdate:
    NSLog(@"A table item was updated");
    break;

进入你的switch语句.编辑:检查了文档后,我发现这两个值不用于Section更改,因此您可以忽略警告或在上面的行中添加null case语句来抑制警告.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读