magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.8k stars 1.79k forks source link

saving always is failure #1156

Closed michaelmou closed 8 years ago

michaelmou commented 8 years ago
let identifier = application.beginBackgroundTaskWithExpirationHandler {

        }

        MagicalRecord.saveWithBlock({ (context) -> Void in

            context.MR_saveWithOptions(MRSaveOptions.SynchronouslyExceptRootContext){ (succeed, error) -> Void in

                if error != nil{
                    print("error focus on saving persistenStore:\(error)")
                }
                application.endBackgroundTask(identifier)

            }

        })
hardikdevios commented 8 years ago

@michaelmou Any Error is printing ?

michaelmou commented 8 years ago

anything is ok, but the parameter of succeed is false.

tonyarnold commented 8 years ago

This is probably the result of a long running error in our logic. The BOOL was not supposed to be an indication of an error occurring — a save might not occur (and thus return NO) if there are no changes to save.

I know, it's a debatable choice. I should verify what Core Data does in this circumstance and copy that.

tonyarnold commented 8 years ago

Yeah, so basically we're just passing back what NSManagedObjectContext gives us. If you try to save a context with no changes, the save result is NO. I don't think we should be going against what the framework does here, but I'm happy to consider arguments for it.