IOS11 master data - NSUnknownKeyException crashes under NameKeyPath with custom property

I use NSFetchedResultsControllerin my application with a custom sectionNameKeyPath(named " formattedDate") to group several items in a table.

A property formattedDateis a property defined in the extension of my NSManagedObject (I use Xcode's automatic codec to determine the class, so I added this property to the extension). This property is not part of the Core Data model (not a temporary property).

extension ActivityMO {
    var formattedDate: String {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "MMMM yyyy"
        return dateFormatter.string(from: endDate as Date!)
    }
}

My app works great on iOS10.

On iOS11, I get the following error and the application crashed:

2017-08-10 11:52:12.735277+0200 *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[< ActivityMO 0x60000048f820> valueForUndefinedKey:]: the entity ActivityMO is not key value coding-compliant for the key "formattedDate".'

What am I doing wrong? Has something changed since iOS11?

Thank,

Axel

+4

Source: https://habr.com/ru/post/1683414/


All Articles