Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Support willSave on newly inserted objects #9

Open
mac-cain13 opened this issue Dec 5, 2014 · 0 comments
Open

Support willSave on newly inserted objects #9

mac-cain13 opened this issue Dec 5, 2014 · 0 comments

Comments

@mac-cain13
Copy link
Owner

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()
        }
      }
    }
@mac-cain13 mac-cain13 changed the title Support Support willSave on newly inserted objects Dec 5, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant