简体   繁体   English

如何在Parse.com的班级中添加另一列? (迅速)

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

I am having some difficulty adding a new column to my class in Parse. 我在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. 任何帮助是极大的赞赏。

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. 通过Parse,您可以延迟将列添加到类中,这意味着您可以将字段添加到PFObject中,如果在Parse类中不存在该字段,则Parse会为您添加该列。

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. 您会注意到,Parse将在其Web门户上创建一个名为image的新列。

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 如果登录到Parse并在数据视图中(“ Core”应在顶部突出显示),则应该有一些类似于 这个 .

Click + Col and that should give you a new column to add! 单击+ Col ,这将为您添加一个新列!

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. 如果您正在谈论如何具体添加图像,我会将图像的URL作为字符串存储在Parse中,并在应用程序中异步加载图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM