(Using swift / Xcode beta 3)
I have two entities in my project - a parent entity which has a one-to-many relationship with its children. When adding new objects before saving the context, everything works fine. However, after restarting the app and fetching parent object again I'm receiving 'relationship fault' for all of its children. This is how I'm saving my context :
func saveContext () {
var error: NSError? = nil
let appDel:AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
let context = appDel.managedObjectContext
if context == nil {
return
}
if !context.hasChanges {
return
}
if context.save(&error) {
return
}
println("Error saving context: \(error?.localizedDescription)\n\(error?.userInfo)")
abort()
}
I tried changing includesSubentities = true and setReturnsObjectsAsFaults = false but it doesn't seem to help. Most of the answers to 'relationship fault' problem with Objective-C seemed to use setRelationshipKeyPathsForPrefetching but using it with NSFetchRequest in Swift seems to be impossible.
Is there something I'm missing?