How to add another column to my class in Parse.com

2019-06-11 04:13发布

问题:

I am having some difficulty adding a new column to my class in Parse. Currently I have made a class (named: Venue Data) with the name and geopoints of restaurants. I would like to add to that class a column for image which will be paired respective to the specific restaurant. I am quite stumped as to how I should go about it. Any help is greatly appreciated.

回答1:

Parse allows you to add columns to a class lazily, meaning that you can add a field to your PFObject and if it is not present in your Parse class, Parse will add that column for you.

Here's how you would add a column via code:

// Prepare image
let imageData = UIImagePNGRepresentation(yourImage)
let imageFile = PFFile(name:"image.png", data:imageData) // "image.png" is the name which would be shown on Parse.com

// Add the new field to your object
yourObject["image"] = imageFile
yourObject.saveInBackground()

You'll notice that Parse will create a new column named image on their web portal.



回答2:

If you log in to Parse and are in your data view ("Core" should be highlighted at the top), you should have a few options that look like .

Click + Col and that should give you a new column to add!

If you're talking about how you would go about adding images specifically, I would store the URLs of the images as a string in Parse and load asynchronously the images in your app.