39 votes     2 answers     32.3k views
over 1 year ago
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: http://mynameisadam.net/PFRelations.zip (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
over 1 year ago
As requested here is a screenshot of the database used in the example image above: