这个CoreData错误意味着什么?

时间:2015-09-04 12:01:34

标签: ios swift core-data error-handling

编译此代码:

func managedObjectContext_roster() -> NSManagedObjectContext {
    return Messenger.sharedInstance.xmppRosterStorage!.mainThreadManagedObjectContext
}

我收到了下一个错误:

CoreData: error: Failed to call designated initializer on NSManagedObject class 'XMPPUserCoreDataStorageObject'

此错误的含义以及如何解决?我在谷歌搜索过,但没有找到任何东西

更新

func fetchedResultsController() -> NSFetchedResultsController? {
    if fetchedResultsControllerVar == nil {
        let moc = MessengerRoster.sharedInstance.managedObjectContext_roster() as NSManagedObjectContext?
        let entity = NSEntityDescription.entityForName("XMPPUserCoreDataStorageObject", inManagedObjectContext: moc!)
        let sd1 = NSSortDescriptor(key: "sectionNum", ascending: true)
        let sd2 = NSSortDescriptor(key: "displayName", ascending: true)

        let sortDescriptors = [sd1, sd2]
        let fetchRequest = NSFetchRequest()

        fetchRequest.entity = entity
        fetchRequest.sortDescriptors = sortDescriptors
        fetchRequest.fetchBatchSize = 10

        fetchedResultsControllerVar = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: moc!, sectionNameKeyPath: "sectionNum", cacheName: nil)
        fetchedResultsControllerVar?.delegate = self

        if fetchedResultsControllerVar?.performFetch(nil) == nil {
            //Handle fetch error
        }
    }

    return fetchedResultsControllerVar!
}

0 个答案:

没有答案