gpt4 book ai didi

ios - Parse 不允许我为同一用户注册创建 4 行信息

转载 作者:行者123 更新时间:2023-11-30 13:28:49 24 4
gpt4 key购买 nike

我正在使用 Parse 在 Swift 上创建一个注册表来存储数据。用户最多可以从给定的事件列表中选择 4 项事件。

我希望表能够单独存储所选的所有 4 条记录。但代码只创建一条记录!

这是代码片段-

//Creating a NSMutableSet to avoid multiple selection of same sport.
var tempSport = NSMutableSet()
//The vales in tempSport are : ["Activity1", "Activity2", "Activity3", "Activity4"]


@IBAction func getStartedButton(sender: AnyObject) {

if tempSport.count < 1
{
//Display Alert
}

else
{

var sendSport = Array(tempSport.allObjects)

print(sendSport)

for sport in sendSport
{
SportList["SportPlayer"] = user.username

SportList["SportPlaying"] = String(sport)

SportList.saveInBackground()
}

}

}

Image Link. Click here to see the expected output and output produced

最佳答案

只需使用数组保存对象,而不是 4 个单独的对象

let object = PFObject(className: "Your Class Name"
object["Sport Playing"] = [activity1, activity2, activity3, activity4]
object.saveInBackground()

希望这有帮助。

关于ios - Parse 不允许我为同一用户注册创建 4 行信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36815989/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com