Xcode 6 Beta 4:使用未解析的标识符'NSFetchedResultsChangeInsert'

Cod*_*oob 3 xcode ios swift

刚刚安装了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
    }
}
Run Code Online (Sandbox Code Playgroud)

Mar*_*n R 7

当枚举时

typedef NS_ENUM(NSUInteger, NSFetchedResultsChangeType) {
    NSFetchedResultsChangeInsert = 1,
    NSFetchedResultsChangeDelete = 2,
    NSFetchedResultsChangeMove = 3,
    NSFetchedResultsChangeUpdate = 4
} ;
Run Code Online (Sandbox Code Playgroud)

映射到Swift,从枚举值中自动删除公共前缀:

enum NSFetchedResultsChangeType : UInt {
    case Insert
    case Delete
    case Move
    case Update
}
Run Code Online (Sandbox Code Playgroud)

比较" 使用Swift with Cocoa和Objective-C"文档中的" 与C API交互 ".

所以你的代码应该是这样的

func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) {
    switch type {
        case .Insert:
            self.tableView.insertSections(NSIndexSet(index: sectionIndex), withRowAnimation: .Fade)
        case .Delete:
            self.tableView.deleteSections(NSIndexSet(index: sectionIndex), withRowAnimation: .Fade)
        default:
            return
    }
}
Run Code Online (Sandbox Code Playgroud)

提示:如果您在Xcode中创建了一个"主 - 细节"应用程序并选择了"使用核心数据",您将获得可以开始的示例代码.