jay patel:
How can i assign Relationship objects [which having to-many relationship to entity] back to entity after modifying or adding new object in relations objects?. Right now what i'm actually doing is after getting all relationship objects i'm assigning it to selectedQA array and after modifying or adding new object in this selectedQA i'm reassigning it back to entity. I'm not sure this is right way or not. Please help me with this.
var selectedQA = [SurveyQA]() //Temporary array
var survey:SurveyList //Main Entity Object
Getting objects from relationship and asssigning to temp Object
if let surveyQAs = survey.surveyQARelation?.allObjects as? [SurveyQA] {
selectedQA = surveyQAs
}
For saving back to Relationship objects
survey.surveyQARelation = NSSet(array: selectedQA)
try! coreDataManager.managedContext.save()
Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE