CoreDataKit
CoreDataKit copied to clipboard
Support willSave on newly inserted objects
CoreData doesn't call willSave for newly inserted objects. So many of my projects include this "fix", maybe CoreDataKit could include this as a optional fix that you can enable?!
// Apply "fix" so willSave is also called for inserted objects
NSNotificationCenter.defaultCenter().addObserverForName(NSManagedObjectContextWillSaveNotification, object: nil, queue: NSOperationQueue.mainQueue()) { notification in
if let managedObjectContext = notification.object as? NSManagedObjectContext {
for managedObject in managedObjectContext.insertedObjects {
managedObject.willSave()
}
}
}