How to add another column to my class in Parse.com? (Swift)

為{幸葍}努か 提交于 2019-12-08 10:32:06

问题


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.



来源:https://stackoverflow.com/questions/31282599/how-to-add-another-column-to-my-class-in-parse-com-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!