You're looking at our questions archive. This question was last updated almost 3 years ago.

If you're looking for help, head over to the Parse Developers Google Group or check out the tag on Stack Overflow.

Help Google Group Stack Overflow

Free Open Source iOS App: PFRelation Helper

41 votes 2 answers 44.4k views almost 3 years ago

Hi there,

Last night I was in need of a quick and dirty way to quickly get relationships set up between PFObjects, so after a couple of hours of work I wrote up a handy little app that does just that. I just thought I would post the xCode project on here for others to use until the actual Parse Data Browser has similar functionality incorporated.

Download here: (Compiled under iOS 6 for the iPhone, latest xCode build).

The app is separated into 3 simple steps. Step 1 involves entering a class name of parent PFObjects to display, along with an attribute name, a class name of children PFObjects to display, along with - again - an attribute name, and a *relationship attribute name.

attribute name: This is an attribute on your objects that will be used to refer to the object, preferably an NSString. relationship attribute name: This is the actual name of the relationship on your parent PFObject that you want to connect your children objects to.

Step 2 then displays a list of PFObjects contained in the parent class you described. Picking one of these parents moves on to the third and final step, where you are presented with a list of children objects that can be connected to the chosen parent PFObject, along with UISwitches beside each child reflecting their current state in the relationship (On being that they are in the relationship, Off being that they aren't).

Finally, the app will remember whatever you entered in Step 1 the last time you had the app open, to save on time when you're just debugging your relationships.

Anyways, it is by far no major accomplishment or anything (the code is far from pretty), just a little app I wrote to help me develop with Parse, so I thought I would just pass it on to you guys. Feel free to modify / improve it to suit your needs, and remember to jump into the App Delegate and modify the Parse initialization to work with whatever app you're planning on working with (I have included a #warning that you can jump to to find the line you need to modify, it's in the applicationDidFinishLaunching method).

Here are some images of the app in action using an example of connecting Employee PFObjects to Job PFObjects via a relationship on the Job PFObject called "payroll". Enjoy!

![App in action]2

It would be nice if you would show us how the Class looks like too, from the Data Browser. Nice work.

- Martin Skow Røed about 4 years ago

Im not sure what you mean by that. You want me to show you how the class I used in the above screenshot looks in the Data Browser? Or you want me to display the class with all of it's attributes inside the app itself? The latter one doesn't seem possible as Parse doesn't allow us to query for attribute names of a PFObject.

- Adam Eisfeld about 4 years ago

No, I was talking about the first one. :) Just a single screenshot of the db in Data Browser.

- Martin Skow Røed about 4 years ago

Done, check out the answer at the bottom.

- Adam Eisfeld about 4 years ago

This is pretty cool, would you consider hosting it on github so people can contribute code to it?

- Chris Burris about 4 years ago

it's awesome! thanks :)

- maziyar PANAHI about 4 years ago

Having some problems getting this to work, when I move to step 3, my app crashes: 2013-01-03 22:58:12.183 PFRelations[85366:c07] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' setObjectForKey: object cannot be nil (key: classname)' *** First throw call stack: (0x254e012 0x1eafe7e 0x25d10de 0x15eda 0x15f1b 0x15f6b 0x16fe3 0x540d 0x1706b 0x4ee93 0x291153f 0x2923014 0x29137d5 0x24f4af5 0x24f3f44 0x24f3e1b 0x212b7e3 0x212b668 0xdf765c 0x2efd 0x2e25) libc++abi.dylib: terminate called throwing an exception (lldb)

- AJ Siegel about 4 years ago

i think it is happening somewhere here: childObjects = [[NSMutableArray alloc] initWithArray:objects];

    relationship = [parentObject relationforKey:[delegate step3RelationshipNameForConnection]];

    PFQuery *relationshipQuery = [relationship query];
- AJ Siegel about 4 years ago

Are you filling out all of the text boxes before you proceed to step 3? If you're leaving a text box blank, then the delegate will return a nil value when asked for the relationshipNameForConnection, which in turn will raise this exception.

- Adam Eisfeld about 4 years ago

Adam, thank you for replying so quickly. I am filling in all fields with the following:

Parent Class Name: workouts Attribute: workout_title

Child Class Name: exercises Attribute: exercise_title

Relation: steps

- AJ Siegel about 4 years ago

Beautiful! Thank you - I've been having real difficulties assigning existing users into a new PFRole object, but this worked perfectly. Note - the User class is actually called User, and the Role class is actually called Role

- SimonB almost 4 years ago

i have the same problem that getting this app to work when i move to step 3 app crashed which is download from above linke. even i am not leave any textfield.thats why i am wondering why its crashed?

- madhan almost 4 years ago

2 Answers

Just submitting this answer so I can accept it, as this isn't a question.

This is very handy and thank you, but Parse's Data Browser really needs to have a way to add and change relationships!

- Andrew Milham about 4 years ago

You can now create/update/delete relations and pointers in the Data Browser.

- Héctor Ramos almost 4 years ago

As requested here is a screenshot of the database used in the example image above:

![alt text]1