added utility to refresh an object

This commit is contained in:
John Estropia
2015-08-19 12:19:14 +09:00
parent 67ccae4ef6
commit b92ee76907

View File

@@ -58,4 +58,20 @@ public extension NSManagedObject {
self.setPrimitiveValue(value, forKey: KVCKey)
self.didChangeValueForKey(KVCKey)
}
/**
Re-faults the object to use the latest values from the persistent store
*/
public func refreshAsFault() {
self.managedObjectContext?.refreshObject(self, mergeChanges: false)
}
/**
Re-faults the object to use the latest values from the persistent store and merges previously pending changes back
*/
public func refreshAndMerge() {
self.managedObjectContext?.refreshObject(self, mergeChanges: true)
}
}