Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Parse - Creating a PFObject

Hi, I'm a bit confused. I have been reading the parse documentation about PFObjects, and it seems you can 'lazily' create a class within Parse, with 'properties' and you can link this to other PFObjects.

Example from Parse Documentation. PFObject *gameScore = [PFObject objectWithClassName:@"GameScore"]; gameScore[@"score"] = @1337; gameScore[@"playerName"] = @"Sean Plott"; gameScore[@"cheatMode"] = @NO; [gameScore saveInBackground];

I would have thought in some situations the class would need to be configured in Xcode? e.g. a class named 'GameScore' should be set up in Xcode as there may be other instances where you need to reference it?

Hopefully this makes sense! Thanks, Alex

2 Answers

The "class" for Parse is not the same as class in Objective-C (though you can actually dynamically create a class with Objective-C as well, but that's waaaaay advanced).

A PFObject simply wraps around and imitate the concept of a class using a key-value store similar to that of a dictionary built on top of a relational backing. The constructor objectWithClassName: still returns an object of the class PFObject.

Great - thank you!

So is it possible then to create an instance of a class in objective-C and convert it to PFObject to store the values in parse?

Any idea where I could find info on how to do this?

Is there a best practise to guide you on whether it is best to create the class in objective c or parse?

Thanks,