刚刚安装了Xcode 6 Beta 4,之前编译的代码现在在NSFetchedResultsChangeType的每个开关上都有“Unresolved Identifier”失败 . 我检查了发行说明,当然还要通过这里搜索,看看是否有其他人经历过这个,但到目前为止还没有任何结果 . 任何信息表示赞赏!
谢谢!
func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) {
println("Running CoreDataTVC.controllerDidChangeSection")
switch type {
case NSFetchedResultsChangeInsert:
self.tableView.insertSections(NSIndexSet(index: sectionIndex), withRowAnimation: .Fade)
case NSFetchedResultsChangeDelete:
self.tableView.deleteSections(NSIndexSet(index: sectionIndex), withRowAnimation: .Fade)
default:
return
}
}
2 回答
当枚举时
映射到Swift,从枚举值中自动删除公共前缀:
比较"Using Swift with Cocoa and Objective-C"文档中的"Interacting with C APIs" .
所以你的代码应该是这样的
提示:如果您在Xcode中创建了一个“主 - 细节”应用程序并选择了“使用核心数据”,您将获得可以开始的示例代码 .
枚举NSFetchedResultsChangeType在NSFetchedResultsController内定义 .
要访问枚举值,您可以使用枚举类型,然后使用如下情况:
既然您知道类型类型是
NSFetchedResultsChangeType
,您也可以从开关案例中省略它,只需使用case .Insert:
和case .Delete: