read
When you save a PFObject and encounter the error Found a circular dependency when saving, it could be due to you setting a bidirectional/inverse relationship.
Take this example:
// You have 2 Parse Class Teacher and Student
PFObject *teacher, student;
// You try to set up the bidirectional relationship
teacher.student = student
student.teacher = teacher
Upon save, the code will throw the exception Found a circular dependency when saving. This is because bidirectional relationship is not supported on Parse.
The solution requires 3 steps:
- Don’t set up any of the relationship, and save
teacherfirst. Saving will provideteacher.objectId. - Then save
studentwith 1 directional relationship toteacher. Saving will providestudent.objectId. - Then update
teacherwith the relation tostudent.
This takes 3 API requests to set up.
Not good, but workaround the limitation of Parse.