Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: How to assign relationship to-many relationship object back to entity?

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


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: How to assign relationship to-many relationship object back to entity?

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×